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

Pass an arbitrary number of arguments to event listener. #15

Merged
merged 3 commits into from
Jul 2, 2016
Merged

Pass an arbitrary number of arguments to event listener. #15

merged 3 commits into from
Jul 2, 2016

Conversation

maccath
Copy link
Contributor

@maccath maccath commented Apr 18, 2015

This PR fixes issue #14

The existing problems, as I understand them, are:

  1. The emit function as defined in Baun\Interfaces\Events expects the second parameter to be an array of arguments, however, when the emit function is called from within the Baun application, this is never the case.
  2. Sometimes multiple arguments are sent when the emit function is called from the Baun application, but due to the Events provider only handling one argument, anything after the first argument is simply ignored.
  3. The emit method in Baun\Providers\Events sends the arguments in an array to League\Event\Emitter's emit function, which is incorrect; it doesn't expect an array of parameters, it expects any arbitrary number of parameters which it accesses via user_func_get_args()

So, I have modified Baun\Interfaces\Events to not take an $args parameter. Instead, it can take an arbitrary number of additional arguments which it will call League\Event\Emitter::emit using call_user_func_array() with an array of arguments from func_get_args().

Hopefully this now makes the Baun framework consistent with Leage\Event and behave in the way that most people will expect it to. :)

maccath added 2 commits April 18, 2015 17:12
It was not possible to actually edit navigation nodes as array objects are
not passed by reference.

 - Create new $navigationObject that is passed by reference
 - Update $navigation array with changes to $navigationObject->nodes
 - Maintain backwards compatibility
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.

2 participants