-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[WIP] make the app/config/services.yml file use the new Symfony autoregistration and autowiring features. #483
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
Conversation
IMO, we should not merge it until we have a 3.3 release in Symfony, to be able to keep releasing the demo project |
Yes that's the plan! |
* Must be protected to allow Symfony DIC to create a proxy. | ||
* | ||
*/ | ||
protected function getSlugger(): Slugger |
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 breaks compat with PHP 5.x, while the demo still supports it for now
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.
True! I will update the 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.
@hhamon thanks for this proposal. I've left some comments. They are not positive ... but my intention is not negative either.
I'm just trying to put myself in the Symfony newcomers place and think what things could/would confuse me. Most of them are probably because of how new this way to work is and they'll fade in time. Thanks!
@@ -13,6 +13,7 @@ | |||
|
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.
These SecurityController.php changes are the perfect example of why I don't like this new way of developing in Symfony. You remove 1 easy-to-understand line ($helper = $this->get('security.authentication_utils');
) and replace it with 6 lines of code ... including some "class guessing" to import the AuthenticationUtils
class 😕
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 this is to show that we can easily inject dependencies into controllers. In this example, the AuthenticationUtils
service is always used.
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.
Deciding only on the number of line of code is dangerous. As discussed in symfony/symfony#21623, the bigger issue with $container->get('foo')
is that you get no guarantee whatsoever about what you'll get back - no contrat. It's working "by luck" in terms of design. It also hardcodes this service - but it should not be the responsibility of this controller class to decide which object to use her, per IoC/DI principles.
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 also prefer the new way, it looks more like typical PHP. No framework magic.
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 agree with... everyone! :D
The lines of code are important - there is a "perceived complexity" when something has extra lines of code. It's superficial, but, in a sense, people "judge a book bike its cover" by subconsciously seeing a lot of lines of code and thinking that something is complex.
On the other hand, controllers have always behaved differently than other services (where you do need to inject objects and use their methods directly). That's always been unfortunate, and has increased the later-parts of Symfony's learning curve (the base controller shortcuts make it easy to get started... but then you pay a bit more of a price later when you need to learn about services, DI, etc).
In this case, for me, I'm ok with it. But, it does strike me as odd that we still have a mixture of approaches: sometimes (e.g. $this->render()
), we're relying on the base controller and using its shortcut methods. But in other cases, we say that you should inject the service you need? If we're moving towards controllers as services, shouldn't we not extend the base controller anymore? If we didn't, that would be a big problem, as it would increase the boilerplate code for many things. Unless, we added traits with getter injects (which could be used for both controllers and in services). I'm not sure what the best approach is - this just strikes me as walking half-way between 2 worlds.
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.
In fact, does this even work? Since the controller is a service (and I think? that the routing automatically knows to use the service, since it exists), the container is never set, correct? So $this->render()
is broken.
* Must be protected to allow Symfony DIC to create a proxy. | ||
* | ||
*/ | ||
protected function getSlugger(): Slugger |
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.
My guess is that this feature will confuse a lot of users. You add to your class an empty getter ... which during runtime is not empty because somehow Symfony injects the needed code to return what you want to get 😕
@@ -23,7 +25,7 @@ | |||
* | |||
* @author Oleg Voronkovich <[email protected]> | |||
*/ | |||
class RedirectToPreferredLocaleListener | |||
class RedirectToPreferredLocaleSubscriber implements EventSubscriberInterface |
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.
Just asking: is this change needed because of Symfony ... or is it because you configured this: resource: '../../src/AppBundle/{EventListener/*Subscriber.php,...}'
In other words ... if the previous config was: resource: '../../src/AppBundle/{EventListener,...}'
would this change be required?
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 may encourage to produce EventSubscriber
s in favor of regular EventListener
s. We can indeed simplify the resource
to regiter all classes in the EventListener/
directory. Because later we also override the listener class to complete its definition.
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.
Now that event subscribers can be made private, the new best practice should be to always use them in place of listeners. Thus, I think also that not advertising listeners in symfony-demo is a good thing - even if it works the same as before.
# matter as they're referenced here by their real names in the PHP code. | ||
# Symfony is then smart enough to make the corresponding matching when compiling, | ||
# optimizing and dumping the container as a raw PHP class in the cache directory. | ||
AppBundle\Twig\AppExtension: |
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 may introduce some confusion. The reason is that you already configured this service previously as part of:
AppBundle\:
resource: '../../src/AppBundle/{EventListener/*Subscriber.php,Form/Type,Security,Twig,Utils}'
And also:
_instanceof:
Twig_ExtensionInterface:
tags: ['twig.extension']
And now you are partially configuring it ... or completing its configuration:
AppBundle\Twig\AppExtension:
$locales: '%app_locales%'
So ... the AppBundle\Twig\AppExtension
is defined in three different parts of the file 😕
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 first section lets Symfony register the classes from these directories as services. It'll make its best to autowire everything. But some service requires some extra manual configuration when Symfony cannot guess the remaining parts (dependency collision or scalar arguments). This is what the third section does.
The second section called instanceof
allows to append configuration to every definitions that match the rule type. It has nothing to do with autowiring! This is probably the confusing part that must be well taught to newcomers. It's just a way to apply a group of configuration settings to each service definition matching the rule. It's a way to make configuration not repeat itself. This means you can still manually define your services and use the instanceof
section to append the DI tags or extra method calls to your sets of configured 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.
Wow, @hhamon I didn't know about _instanceof
config section. Are there any docs about it? Could be appended to comment to let people know what's the magic behind it.
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.
Documentation doesn't exist yet. This PR is a PoC to experiment the upcoming new DI features of Symfony 3.3. We'll document everything very soon ;)
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.
Ah, I've searched for _instance
here and it was only in config so I thought it is already supported elsewhere.
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 part - where we fill in missing arguments - should stay as it is - this is perfect
app/config/services.yml
Outdated
|
||
app.comment_notification: | ||
class: AppBundle\EventListener\CommentNotificationListener | ||
AppBundle\EventListener\CommentNotificationListener: | ||
arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%'] |
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.
Can't these be autowired?
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.
It can be autowired if we simplify the AppBundle/
section by allowing registering all classes under the EventListener/
directory. However we would still have to manually wire the last argument that is scalar and cannot be guessed by Symfony.
de0a81c
to
3372071
Compare
# "{EventListener/*Subscriber.php,Form/Type/*Type.php}". | ||
AppBundle\: | ||
# Register all classes in the src/AppBundle directory as services | ||
resource: '../../src/AppBundle/{EventListener,Form/Type,Security,Twig,Utils}' |
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.
most form types don't need to be registered as services at all (they need to become services only when they have dependencies).
And as this is broken currently because you define private services, you could avoid doing it for all of them
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 the current implementation is broken. I'm working on a PR to make form type services privatable.
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.
If symfony/symfony-standard#1070 is merged, this will simplify
* Constructor. | ||
* | ||
* @param AuthenticationUtils $helper | ||
*/ |
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 doc block does not bring useful informations, what about removing it?
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.
Fixed thanks.
…egistration and autowiring features.
8cd79f3
to
6c2b65d
Compare
app/AppKernel.php
Outdated
@@ -32,6 +32,7 @@ public function registerBundles() | |||
if (in_array($this->getEnvironment(), ['dev', 'test'])) { | |||
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); | |||
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); | |||
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); | |||
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); | |||
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); |
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.
Could you add WebServerBundle
and SensioGeneratorBundle
to dev
environment only?
Refs: https://github.com/symfony/symfony-standard/blob/master/app/AppKernel.php#L26-L29
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.
Done.
# be lazy instanciated when they're really needed. This is why the inherited | ||
# default "public" attribute is overriden to force the registered controller | ||
# services to be marked public. | ||
AppBundle\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.
WYDT about removing the AppBundle
like in symfony/symfony-standard#1034?
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.
Interesting discussion. I really like the idea of getting rid of the AppBundle.
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'm sorry but we are not going to get rid of AppBundle in the Symfony Demo. For this kind of changes, the Symfony Demo must go behind the Symfony Framework itself. If Symfony decides to go bundle-less for Symfony 4.0 (I wish it will) then we'll update the Symfony Demo accordingly. But we can't do that before. I'm sorry.
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 can still create PR to test this setup without merging it.
/** | ||
* Must be protected to allow Symfony DIC to create a proxy. | ||
*/ | ||
protected function getSlugger() |
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 would not advertise this feature in the demo (it's for advanced users). Using constructor injection is OK here and works out of the box.
It's also easier to understand for newcomers.
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 I have the same feeling as well.
@@ -13,6 +13,7 @@ | |||
|
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 also prefer the new way, it looks more like typical PHP. No framework magic.
# Thus, its class is not namespaced and cannot be defined in a global rule. | ||
# Indeed, registering new classes whose filename matches a glob pattern as | ||
# services like in the two previous sections only works for namespaced classes. | ||
app.twig.intl_extension: |
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.
Would we want this to also match the class name?
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.
Yea, I think it should be:
# register vendor class a service
Twig_Extensions_Extension_Intl: ~
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.
If I do that, I get this error:
RuntimeException in CheckDefinitionValidityPass.php line 52:
The definition for "Twig_Extensions_Extension_Intl" has no class attribute, and
appears to reference a class or interface in the global namespace. Leaving out
the "class" attribute is only allowed for namespaced classes. Please specify the
class attribute explicitly to get rid of this error.
…configuration (weaverryan) This PR was squashed before being merged into the 3.3-dev branch (closes #22234). Discussion ---------- [DI] Introducing autoconfigure: automatic _instanceof configuration | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes (mostly, a continuation of a new feature) | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#7538 This is a proposal to allow the user to opt into some automatic `_instanceof` config. Suppose I want to auto-tag all of my voters and event subscribers ```yml # current services: _defaults: autowire: true _instanceof: Symfony\Component\Security\Core\Authorization\Voter\VoterInterface: tags: [security.voter] Symfony\Component\EventDispatcher\EventSubscriberInterface: tags: [kernel.event_subscriber] # services using the above tags AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` If I'm registering a service with a class that implements `VoterInterface`, when would I ever *not* want that to be tagged with `security.voter`? Here's the proposed code: ```yml # proposed services: _defaults: autowire: true autoconfigure: true # services using the auto_configure_instanceof functionality AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` The user must opt into this and it only applies locally to this configuration file. It works because each enabled bundle would have the opportunity to add one or more "automatic instanceof" definitions - e.g. SecurityBundle would add the `security.voter` instanceof config, FrameworkBundle would add the `kernel.event_subscriber` instanceof config, etc. For another example, you can check out the proposed changes to `symfony-demo` - symfony/demo#483 - the `_instanceof` section is pretty heavy: https://github.com/hhamon/symfony-demo/blob/81694ac21e63bebe7ecfa22fa689766f2f38ccd5/app/config/services.yml#L20 Thanks! Commits ------- 18627bf [DI] Introducing autoconfigure: automatic _instanceof configuration
…configuration (weaverryan) This PR was squashed before being merged into the 3.3-dev branch (closes #22234). Discussion ---------- [DI] Introducing autoconfigure: automatic _instanceof configuration | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes (mostly, a continuation of a new feature) | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#7538 This is a proposal to allow the user to opt into some automatic `_instanceof` config. Suppose I want to auto-tag all of my voters and event subscribers ```yml # current services: _defaults: autowire: true _instanceof: Symfony\Component\Security\Core\Authorization\Voter\VoterInterface: tags: [security.voter] Symfony\Component\EventDispatcher\EventSubscriberInterface: tags: [kernel.event_subscriber] # services using the above tags AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` If I'm registering a service with a class that implements `VoterInterface`, when would I ever *not* want that to be tagged with `security.voter`? Here's the proposed code: ```yml # proposed services: _defaults: autowire: true autoconfigure: true # services using the auto_configure_instanceof functionality AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` The user must opt into this and it only applies locally to this configuration file. It works because each enabled bundle would have the opportunity to add one or more "automatic instanceof" definitions - e.g. SecurityBundle would add the `security.voter` instanceof config, FrameworkBundle would add the `kernel.event_subscriber` instanceof config, etc. For another example, you can check out the proposed changes to `symfony-demo` - symfony/demo#483 - the `_instanceof` section is pretty heavy: https://github.com/hhamon/symfony-demo/blob/81694ac21e63bebe7ecfa22fa689766f2f38ccd5/app/config/services.yml#L20 Thanks! Commits ------- 18627bf9f6 [DI] Introducing autoconfigure: automatic _instanceof configuration
…configuration (weaverryan) This PR was squashed before being merged into the 3.3-dev branch (closes #22234). Discussion ---------- [DI] Introducing autoconfigure: automatic _instanceof configuration | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes (mostly, a continuation of a new feature) | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#7538 This is a proposal to allow the user to opt into some automatic `_instanceof` config. Suppose I want to auto-tag all of my voters and event subscribers ```yml # current services: _defaults: autowire: true _instanceof: Symfony\Component\Security\Core\Authorization\Voter\VoterInterface: tags: [security.voter] Symfony\Component\EventDispatcher\EventSubscriberInterface: tags: [kernel.event_subscriber] # services using the above tags AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` If I'm registering a service with a class that implements `VoterInterface`, when would I ever *not* want that to be tagged with `security.voter`? Here's the proposed code: ```yml # proposed services: _defaults: autowire: true autoconfigure: true # services using the auto_configure_instanceof functionality AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` The user must opt into this and it only applies locally to this configuration file. It works because each enabled bundle would have the opportunity to add one or more "automatic instanceof" definitions - e.g. SecurityBundle would add the `security.voter` instanceof config, FrameworkBundle would add the `kernel.event_subscriber` instanceof config, etc. For another example, you can check out the proposed changes to `symfony-demo` - symfony/demo#483 - the `_instanceof` section is pretty heavy: https://github.com/hhamon/symfony-demo/blob/81694ac21e63bebe7ecfa22fa689766f2f38ccd5/app/config/services.yml#L20 Thanks! Commits ------- 18627bf9f6 [DI] Introducing autoconfigure: automatic _instanceof configuration
…configuration (weaverryan) This PR was squashed before being merged into the 3.3-dev branch (closes #22234). Discussion ---------- [DI] Introducing autoconfigure: automatic _instanceof configuration | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes (mostly, a continuation of a new feature) | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#7538 This is a proposal to allow the user to opt into some automatic `_instanceof` config. Suppose I want to auto-tag all of my voters and event subscribers ```yml # current services: _defaults: autowire: true _instanceof: Symfony\Component\Security\Core\Authorization\Voter\VoterInterface: tags: [security.voter] Symfony\Component\EventDispatcher\EventSubscriberInterface: tags: [kernel.event_subscriber] # services using the above tags AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` If I'm registering a service with a class that implements `VoterInterface`, when would I ever *not* want that to be tagged with `security.voter`? Here's the proposed code: ```yml # proposed services: _defaults: autowire: true autoconfigure: true # services using the auto_configure_instanceof functionality AppBundle\Security\PostVoter: ~ AppBundle\EventListener\CheckRequirementsSubscriber: ~ ``` The user must opt into this and it only applies locally to this configuration file. It works because each enabled bundle would have the opportunity to add one or more "automatic instanceof" definitions - e.g. SecurityBundle would add the `security.voter` instanceof config, FrameworkBundle would add the `kernel.event_subscriber` instanceof config, etc. For another example, you can check out the proposed changes to `symfony-demo` - symfony/demo#483 - the `_instanceof` section is pretty heavy: https://github.com/hhamon/symfony-demo/blob/81694ac21e63bebe7ecfa22fa689766f2f38ccd5/app/config/services.yml#L20 Thanks! Commits ------- 18627bf9f6 [DI] Introducing autoconfigure: automatic _instanceof configuration
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're just about stable enough (we should be, it's beta!) to finish this. @hhamon would you have time in the next few days or week so we can get it ready and test before release? It's also a good test case for the features :)
# and dumped to raw PHP code. | ||
_defaults: | ||
autowire: true | ||
public: false |
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.
Add the new autoconfigure: true
# "{EventListener/*Subscriber.php,Form/Type/*Type.php}". | ||
AppBundle\: | ||
# Register all classes in the src/AppBundle directory as services | ||
resource: '../../src/AppBundle/{EventListener,Form/Type,Security,Twig,Utils}' |
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.
If symfony/symfony-standard#1070 is merged, this will simplify
# Thus, its class is not namespaced and cannot be defined in a global rule. | ||
# Indeed, registering new classes whose filename matches a glob pattern as | ||
# services like in the two previous sections only works for namespaced classes. | ||
app.twig.intl_extension: |
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.
Yea, I think it should be:
# register vendor class a service
Twig_Extensions_Extension_Intl: ~
# matter as they're referenced here by their real names in the PHP code. | ||
# Symfony is then smart enough to make the corresponding matching when compiling, | ||
# optimizing and dumping the container as a raw PHP class in the cache directory. | ||
AppBundle\Twig\AppExtension: |
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 part - where we fill in missing arguments - should stay as it is - this is perfect
@@ -86,7 +86,7 @@ public function newAction(Request $request) | |||
// However, we explicitly add it to improve code readability. | |||
// See http://symfony.com/doc/current/best_practices/forms.html#handling-form-submits | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
$post->setSlug($this->get('slugger')->slugify($post->getTitle())); | |||
$post->setSlug($this->getSlugger()->slugify($post->getTitle())); |
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.
Now, we should pass this in as an argument to the controller:
public function newAction(Request $request Slugger $slugger)
{ | ||
$this->helper = $helper; | ||
} | ||
|
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.
Remove, and move below:
public function loginAction(AuthenticationUtils $authUtils)
This needs to wait for symfony/symfony#22701
tags: | ||
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } | ||
Twig_ExtensionInterface: | ||
tags: ['twig.extension'] |
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.
All of these _instanceof
can be removed thanks to autoconfigure
- I don't think we'll need any _instanceof
in this file.
I'm finishing this PR in #562. Hugo, I'm sorry but I couldn't reuse your original commits because there were too many conflicts (and because Symfony changed the way some of these new features work too). Thanks! |
This PR will work as expected when the following PRs will be merged in the main Symfony repository: