zendframework/zf2 — pull request #5950 by radnan (2014-03-11 18:56:33+00:00)
Title: Ability to attach/detach shared listeners from `AbstractListenerAggregate`

Adding the ability to attach and detach shared event listeners by their id. Simply append the listener returned by the shared event manager to the `$sharedListeners` property:

~~~php
listeners[] = $events->attach('foo', array($this, 'fooCallback'));

$sharedEvents = $events->getSharedManager();
$id = 'Zend\Stdlib\DispatchableInterface';
$this->sharedListeners[$id][] = $sharedEvents->attach($id, 'foo.bar', array($this, 'fooBarCallback'));
}
}
~~~

I've also cleaned up the `ViewManager` and moved the event listening logic to each individual listener's `attach()` method. This allows us to detach `RouteNotFoundStrategy` for example [without having to resort to hacks](http://stackoverflow.com/q/21490045/2257808).