-
-
Notifications
You must be signed in to change notification settings - Fork 130
Conversation
Not sure how to handle getCommentForm. This method is used accross several actions. Should I create an abstract action or should we duplicate this piece of code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, love this change to Actions 👍
*/ | ||
private $collectionManager; | ||
|
||
public function __construct(BlogInterface $blog, PostManagerInterface $postManager, CollectionManagerInterface $collectionManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is over 120 chars, can you make it multiline.
src/Action/ModerateCommentAction.php
Outdated
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
class ModerateCommentAction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
public function __invoke(Request $request, $year, $month) | ||
{ | ||
return $this->renderArchive($request, [ | ||
'date' => $this->getPostManager()->getPublicationDateQueryParts(sprintf('%d-%d-%d', $year, $month, 1), 'month'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
over 120 chars
'route_parameters' => $request->get('_route_params'), | ||
], $parameters); | ||
|
||
$response = $this->render(sprintf('@SonataNews/Post/archive.%s.twig', $request->getRequestFormat()), $parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is over 120 chars
/** | ||
* @param null|SeoPageInterface $seoPage | ||
*/ | ||
public function setSeoPage(SeoPageInterface $seoPage = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? (It will be replaced with Trait?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, after merging sonata-project/SonataSeoBundle#274
@@ -39,6 +39,7 @@ public function load(array $configs, ContainerBuilder $container) | |||
$bundles = $container->getParameter('kernel.bundles'); | |||
|
|||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | |||
$loader->load('actions.xml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything is singular, this one is plural 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already had this discussion:
sonata-project/SonataAdminBundle#5120 (comment)
Would prefer singular too, but symfony is mainly using plural for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, we should rename others then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to do this
private $postManager; | ||
|
||
/** | ||
* AbstractPostArchiveAction constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed?
* AbstractPostArchiveAction constructor. | ||
* | ||
* @param BlogInterface $blog | ||
* @param PostManagerInterface $postManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed too IMO, and I thought you were against removing it but now I see you did not put it on some methods below.
src/Action/HomeAction.php
Outdated
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
final class HomeAction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could reuse this and get entirely rid of that action: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php#L57
This is so much cleaner! I was going to ask you to split the test , but I realise there is none :P |
007f33f
to
142d1b9
Compare
'route_parameters' => $request->get('_route_params'), | ||
], $parameters); | ||
|
||
$response = $this->render( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@covex-nn , apparently you're doing a series of PR to decouple from the templating component, I didn't realise that when I made my PR. Maybe we could entirely skip the extends Controller
and use $response->setContent($this->twig->render($view, $parameters))
? Or is it wrong/to soon? See https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php#L224
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too soon. We still support symfony 2.8: https://github.com/symfony/symfony/blob/2.8/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php#L184-L190
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greg0ire PR about controller actions and PR about decoupling from templating are not related to each other (my PR was about using templating service inside blocks). So, i think, if you would inject twig into controller action, it will work. But, may be some other actions use other Controller/ControllerTrait features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe yeah, but there's probably not that many, and if it can spare us from injecting the whole container, then it might be good. I might try it on the new actions I created but technically it will be a BC-break.
Anything to do here? @greg0ire @covex-nn @kunicmarko20 |
Experimenting with the |
|
||
return $response; | ||
return $action->renderArchive($this->resolveRequest($request), $criteria, $parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hard / impossible in a BC way. So I will do this on the master branch afterwards |
Thanks @core23 ! |
I am targeting this branch, because this is BC.
Changelog
Todo
NEXT_MAJOR
commentsAction
namespaceSubject
Using invokable CaaSes vs one big controller achieves several things:
Refs sonata-project/SonataAdminBundle#5120