Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged branch mtdowling/event_dispatcher_add_iterator (PR symfony#5268)
Commits ------- 0ad00f8 [EventDispatcher] Adding IteratorAggregate to GenericEvent Discussion ---------- [EventDispatcher] Adding IteratorAggregate to GenericEvent --------------------------------------------------------------------------- by drak at 2012-08-16T07:43:29Z What is the use case for this that it should be part of the Generic event? --------------------------------------------------------------------------- by mtdowling at 2012-08-16T17:12:28Z This allows for the GenericEvent to be even more generic. Now listeners don't need to know an exact key from the arguments, but rather can iterate over the arguments to find what they are looking for. This makes the GenericEvent more like an array. --------------------------------------------------------------------------- by mtdowling at 2012-08-17T19:31:04Z How would this be a nasty break? It's just giving the GenericEvent more capabilities with IteratorAggregate. This is a completely separate PR from the one that flipped the constructor args. --------------------------------------------------------------------------- by schmittjoh at 2012-08-17T19:34:47Z Why are you not just doing ``foreach ($event->getArguments() as $arg) { /** ... */ }``? If you just have ``foreach ($event)``, to me at least it would not be so clear what we are actually iterating over. --------------------------------------------------------------------------- by mtdowling at 2012-08-17T19:39:23Z This class already has ArrayAccess. If you're already using this class like an array, then I think you should expect to be able to iterate it like an array. I'm just finishing that concept off by implementing IteratorAggregate. --------------------------------------------------------------------------- by schmittjoh at 2012-08-17T19:47:43Z Indeed, if we already have ArrayAccess which we probably don't want to remove again, then that seems reasonable.
- Loading branch information