This repository was archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Upgrade help from 2x to 3x #75
Copy link
Copy link
Open
Description
Hi @weierophinney,
I try to update zendframework/zend-eventmanager - ^2.6.3 to ^3.0.0 main Problem in
\Zend\EventManager\SharedEventManager::attach was the return removed. We using this return for caching and detach our events. Is there any migration guide I try to do it by self but I am not sure if this be working as before.
Old:
/**
* {@inheritdoc}
*/
public function attach(EventManagerInterface $events, $priority = 1)
{
$sharedEvents = $events->getSharedManager();
$this->listeners[] = $sharedEvents->attach(
Application::class,
MvcEvent::EVENT_BOOTSTRAP,
[$this, 'onBootstrap'],
$priority
);
}
/**
* {@inheritdoc}
*/
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
}New:
public function attach(EventManagerInterface $events, $priority = 1)
{
$sharedEvents = $events->getSharedManager();
$sharedEvents->attach(
Application::class,
MvcEvent::EVENT_BOOTSTRAP,
[$this, 'onBootstrap'],
$priority
);
$this->listeners = $sharedEvents->getListeners([Application::class],
MvcEvent::EVENT_BOOTSTRAP);
}
/**
* {@inheritdoc}
*/
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
$events->detach($listener);
unset($this->listeners[$index]);
}
}Metadata
Metadata
Assignees
Labels
No labels