-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Add ControllerEvent::getAttributes()
to handle attributes on controllers
#46001
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
I wanted do that for ages! Thanks for doing it. But iirc we already had an instance of the reflection somewhere. Can't we reuse it? |
400b10a
to
d15dbbe
Compare
yes we can, updated! |
6f57daa
to
e2d28fe
Compare
92919c9
to
b7231ed
Compare
PR is ready for another round of reviews. @stof, I addressed your comment this way:
Understood and done. Just one thing: because there is
I replaced |
ControllerEvent::getAttributes()
to allow reading/defining attributes on controllersControllerEvent::getAttributes()
to handle attributes on controllers
I missed this comment:
Having
I want everything to remain lazy, that's what the current implementation provides. |
a61ee44
to
4b14fa9
Compare
src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php
Outdated
Show resolved
Hide resolved
4b14fa9
to
09f291f
Compare
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.
👍
@@ -21,22 +21,15 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function createArgumentMetadata(string|object|array $controller): array | |||
public function createArgumentMetadata(string|object|array $controller, \ReflectionClass $class = null, \ReflectionFunction $reflection = null): array |
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 + interface ftw 💚
09f291f
to
946a6e5
Compare
…tes on controllers
Thank you @nicolas-grekas. |
946a6e5
to
0f2293c
Compare
src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php
Show resolved
Hide resolved
… request (nicolas-grekas) This PR was merged into the 6.2 branch. Discussion ---------- [HttpKernel] Don't cache controller's reflector inside the request | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #47461 | License | MIT | Doc PR | - Issue introduced by #46001 Commits ------- c751bd0 [HttpKernel] Don't cache controller's reflector inside the request
…es to other event handlers (#53) This PR uses the new API introduced in symfony/symfony#46001 to read controller attributes through the `ControllerEvent`, and to make them available to other event handlers when replacing the controller. This is necessary when using the ´Send304IfNotModified` attribute in combination with `\Symfony\Component\HttpKernel\Attribute\Cache`. Without this change, `\Symfony\Component\HttpKernel\EventListener\CacheAttributeListener` will not set `Cache` headers accordingly. The result is that you may get `304 Not Modified` responses on conditional requests with `If-Modified-Since`, but these are treated as `stale/cache` only in the HttpCache and have a `Cache-Control: must-revalidate, private` header.
…es to other event handlers (Case 177753) (#15) This adapts webfactory/WebfactoryWfdMetaBundle#53: > This PR uses the new API introduced in symfony/symfony#46001 to read controller attributes through the `ControllerEvent`, and to make them available to other event handlers when replacing the controller. > > This is necessary when using the `Send304IfNotModified` attribute in combination with `\Symfony\Component\HttpKernel\Attribute\Cache`. Without this change, `\Symfony\Component\HttpKernel\EventListener\CacheAttributeListener` will not set `Cache` headers accordingly. The result is that you may get `304 Not Modified` responses on conditional requests with `If-Modified-Since`, but these are treated as `stale/cache` only in the HttpCache and have a `Cache-Control: must-revalidate, private` header. And adds some tests.
Replacing #45457. Paving the way toward #44705