getEventManger(); $this->getServiceLocator()->register( DeliveryMetadataListener::SERVICE_ID, new DeliveryMetadataListener() ); $eventManager->attach( DeliveryCreatedEvent::class, [DeliveryMetadataListener::class, 'whenDeliveryIsPublished'] ); $this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); } public function down(Schema $schema): void { $eventManager = $this->getEventManger(); $this->getServiceLocator()->unregister( DeliveryMetadataListener::SERVICE_ID ); $eventManager->detach( DeliveryCreatedEvent::class, [DeliveryMetadataListener::class, 'whenDeliveryIsPublished'] ); $this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); } private function getEventManger(): EventManager { return $this->getServiceManager()->get(EventManager::SERVICE_ID); } }