Skip to content
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

Fix RegisterEventListenersAndSubscribersPass & event_subscribers service accessibility #196

Merged
merged 3 commits into from
Oct 11, 2012

Conversation

adrienbrault
Copy link
Contributor

No description provided.

$container->getDefinition('jms_serializer.event_dispatcher')
->addMethodCall('setListeners', array(call_user_func_array('array_merge', $listeners)));
foreach ($listeners as $listener) {
$evenDispatcherDefinition->addMethodCall('addListener', $listener);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you are not using the setListeners call anymore? I added it to avoid a single method call per listener.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setListeners do not transform the value it receives.

in RegisterEventListenersAndSubscribersPass, $listeners look like this (ordered by priority):

array(
    array($eventData['event'], array($id, $method), $class, $format),
)

Whereas EventDispatcher\LazyEventDispatcher::$listeners look like:

array(
    'event' => array(
        array(array('id', 'method'), 'type', 'format'),
        array($callable, 'type', 'format'),
        array(array('id', 'method'), 'type', 'format'),
    ),
)

I could also prepare the $listeners array to be set with setListeners, but i felt like it would duplicate some "logic" from the EventDispatcher class ...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this conversion to the compiler pass, and then set the converted data using the setListeners method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@stof
Copy link
Contributor

stof commented Oct 11, 2012

And for the public visibility, the compiler pass should check it IMO

@adrienbrault
Copy link
Contributor Author

@stof Good point, added a commit about that

schmittjoh added a commit that referenced this pull request Oct 11, 2012
Fix RegisterEventListenersAndSubscribersPass & event_subscribers service accessibility
@schmittjoh schmittjoh merged commit 00e8f91 into schmittjoh:master Oct 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants