-
Notifications
You must be signed in to change notification settings - Fork 90
allowing more event identifiers in AbstractController #248
allowing more event identifiers in AbstractController #248
Conversation
I'm not sure this is a good idea tbh. You want to declare extremely common identifiers, and identifiers are shared across ALL of the event managers using same shared event manager, they are not limited to controllers only. I believe proper approach would be to provide marker interfaces for all the controllers in the module: |
@Xerkus a markerinterface works sure, but only for own modules, if you have external dependencies, you have to overwrite all controllers to add a markerinterface. |
]; | ||
|
||
$offset = 0; | ||
for ($i = 0; $i < substr_count($className, '\\'); $i++) { |
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 substr_count
can be assigned to variable for micro-opt
I still oppose addition of namespaces at all levels as identifiers. |
]; | ||
|
||
$offset = 0; | ||
$substrCont = substr_count($className, '\\'); |
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.
s/$substrCont/$substrCount
@Xerkus i can not reopen... |
@kokspflanze can you please describe use case that requires more generic identifiers? |
if you have the following classes
if you enter the |
IMHO this adds too much magic to controllers. MVCs event system is already pretty complex and hard to debug and this would add additional complexity. It might be even harmful for existing projects out there, that rely on the current behavior - therefore it seems to introduce a BC break. Just my 2¢ |
Let me explain my hesitation to accept this PR. Problem with expanding the scope is that identifiers are virtually global with a single shared event manager used throughout the application. Any other EventManager based event driven implementation under Events in zend-mvc are already presenting a pretty steep learning curve. Listeners interacting wrong is not easy to debug already and for someone who is not deeply familiar with framework this side-effect could be pretty devastating. In short, usage of namespace hierarchy as identifiers is a misuse of the feature. To quote the @weierophinney:
So, after some consideration, I decided not to proceed in this direction. Sorry. |
hi =)
my main problem was like zendframework/zendframework#6553, but with a other namespace of my module.
i had 2 modules which has following names
Foobar\Baz
andFoobar\Bar
, with the old logic it was not possible to know which controller module was called. It was everytime justFoobar
in the event identifiers.With the change it will generate a list with different namespaces so it will generate
Foobar
,Foobar\Baz
orFoobar\Bar
.