-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Handle Service/EventSubscriberInterface in ReflectionClassResource #25976
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,9 @@ | |
|
||
namespace Symfony\Component\Config\Resource; | ||
|
||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* @author Nicolas Grekas <p@tchwork.com> | ||
*/ | ||
|
@@ -114,7 +117,9 @@ private function computeHash() | |
|
||
private function generateSignature(\ReflectionClass $class) | ||
{ | ||
yield $class->getDocComment().$class->getModifiers(); | ||
yield $class->getDocComment(); | ||
yield (int) $class->isFinal(); | ||
yield (int) $class->isAbstract(); | ||
|
||
if ($class->isTrait()) { | ||
yield print_r(class_uses($class->name), true); | ||
|
@@ -149,6 +154,16 @@ private function generateSignature(\ReflectionClass $class) | |
yield print_r($defaults, true); | ||
} | ||
} | ||
|
||
if ($class->isSubclassOf(EventSubscriberInterface::class)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering whether this interface coming from another component should really be hardcoded here. This means that any other package providing a similar feature has no way to invalidate the container. Could we make a reusable implementation (using a different resource probably), which would work for such cases ? Note that I have such use case in my own project, and I will soon have it in KnpMenuBundle too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof that's possible, but that's a new feature. Not the target here, but could be done in another PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, actually, other packages can invalidate the cache, but suffer from the issue of invalidating them too often too. Can you work on creating such new feature for 4.1 though ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
not quite now, please open an issue :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done: #25984 |
||
yield EventSubscriberInterface::class; | ||
yield print_r(\call_user_func(array($class->name, 'getSubscribedEvents')), true); | ||
} | ||
|
||
if ($class->isSubclassOf(ServiceSubscriberInterface::class)) { | ||
yield ServiceSubscriberInterface::class; | ||
yield print_r(\call_user_func(array($class->name, 'getSubscribedServices')), true); | ||
} | ||
} | ||
} | ||
|
||
|
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.
$class->getModifiers()
can change value at runtime, e.g. on PHP 5.5