-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make CoreController actions CaaSes #5120
Conversation
src/Controller/SearchAction.php
Outdated
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
if ($request->get('admin') && $request->isXmlHttpRequest()) { |
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.
What about inversing if and putting the default return instead of 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.
I just did this, good call :)
@@ -378,7 +378,7 @@ public function fixTemplates( | |||
|
|||
// set template for simple pager if it is not already overwritten | |||
if ('setPagerType' === $method[0] | |||
&& $method[1][0] === Pager::TYPE_SIMPLE | |||
&& Pager::TYPE_SIMPLE === $method[1][0] |
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 in scope of this PR?
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.
The build will not pass otherwise.
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 idea, I love it!
src/Controller/DashboardAction.php
Outdated
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
final class DashboardAction extends Controller |
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.
Why do you extend the symfony Controller
?
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.
For one thing and one thing only: the render
method. I looked at it, it is fairly complicated because it looks for the templating
component, and for twig
. Not sure if I could safely get rid of it.
src/Controller/DashboardAction.php
Outdated
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Controller; |
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.
Not a blocker, but I would prefer the ..\Action
namespace for actions.
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.
Then maybe also change the name of service file to actions?
@core23 why did you relabel it to minor? I'm going to make another PR for cs. |
Ah I know, that's because of the deprecations, forgot that rule 👍 |
cfe7999
to
09bc8db
Compare
That's one reason. You also introduce new stuff (the action classes), so it's a minor. |
I introduce new classes, but I introduce no new features I think :P |
Made Codacy happy :) |
@@ -141,6 +141,7 @@ public function load(array $configs, ContainerBuilder $container) | |||
$loader->load('block.xml'); | |||
$loader->load('menu.xml'); | |||
$loader->load('commands.xml'); | |||
$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.
action.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.
Why use singular? We use commands and services
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.
What about block and menu?
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 those are faulty, or maybe there is an unspoken rule about when to use singular and when to use plural, all I know is that in Symfony, you have services.yaml
. Either way, fixing this is out of scope of this PR.
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.
Symfony is refering to a services.yaml
:
https://symfony.com/doc/current/service_container.html#service-container-services-load-example
So we should use plurals 👍
Finally managed to test it on a very old project, it doesn't work :P |
1890f0e
to
71cfddd
Compare
Ready for review :) |
greg0ire requested a review (and also, a merge would be nice) from sonata-project/contributors 2 minutes ago |
Thank you, @greg0ire =) |
@greg0ire is happy :) |
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: