/** * Detach all our listeners from the event manager * * @param SharedEventManagerInterface $events * @return void */ public function detachShared(SharedEventManagerInterface $events) { if ($events->detach('Zend\\Mvc\\Application', $this->listener)) { $this->listener = null; } return true; }
/** * {@inheritDoc} */ public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $listener) { $events->detach(self::EVENT_IDENTIFIER, $listener); } unset($this->listeners); }
public function attachShared(SharedEventManagerInterface $events) { $class = $this->getMonitoredClass(); $events->attach($class, 'commit', [$this, 'onAddRevision'], 1); $events->attach($class, 'checkout', [$this, 'onCheckout'], -1); $events->attach($class, 'reject', [$this, 'onReject'], -1); }
/** * @param SharedEventManagerInterface $events */ public function detachShared(SharedEventManagerInterface $events) { foreach ($this->sharedListeners as $index => $listener) { if ($events->detach('ZF\\Rest\\RestController', $listener)) { unset($this->sharedListeners[$index]); } } }
/** * {@inheritdoc} */ public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $id => $listener) { if ($events->detach($id, $listener)) { unset($this->listeners[$id]); } } }
/** * @param SharedEventManagerInterface $events */ public function attachShared(SharedEventManagerInterface $events) { $listener = $events->attach(RestController::class, MvcEvent::EVENT_DISPATCH, [$this, 'onDispatch'], 100); if (!$listener) { $listener = [$this, 'onDispatch']; } $this->sharedListeners[] = $listener; }
/** * @inheritdoc */ public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach(AclService::class, $listener)) { unset($this->listeners[$index]); } } }
public function detachShared(SharedEventManagerInterface $events) { foreach ($this->sharedListeners as $index => $listener) { if ($events->detach($this->eventIdentifier, $listener)) { unset($this->sharedListeners[$index]); } } }
public function attachShared(SharedEventManagerInterface $events) { $monitoredClass = $this->getMonitoredClass(); $events->attach($monitoredClass, 'create', [$this, 'onCreate']); $events->attach($monitoredClass, 'update', [$this, 'onUpdate']); $events->attach($monitoredClass, 'associate', [$this, 'onAssociate']); $events->attach($monitoredClass, 'dissociate', [$this, 'onDissociate']); }
public function attachShared(SharedEventManagerInterface $events) { $class = $this->getMonitoredClass(); $events->attach($class, 'start', [$this, 'onStart']); $events->attach($class, 'comment', [$this, 'onComment']); $events->attach($class, 'archive', [$this, 'onArchive']); $events->attach($class, 'restore', [$this, 'onRestore']); }
/** * @inheritdoc */ public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach(AbstractActionController::class, $listener)) { unset($this->listeners[$index]); } } }
public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $index => $callback) { if ($events->dettach($callback)) { unset($this->listeners[$index]); } } }
public function detachShared(\Zend\EventManager\SharedEventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($this->getMonitoredClass(), $listener)) { unset($this->listeners[$index]); } } }
public function attachShared(SharedEventManagerInterface $events, $priority = null) { $this->priority = $priority; $listeners = array(); $listeners[] = $events->attach($this->identity, 'foo.bar', array($this, 'fooBar')); $listeners[] = $events->attach($this->identity, 'foo.baz', array($this, 'fooBaz')); $this->listeners[\spl_object_hash($events)] = $listeners; return __METHOD__; }
public function attachShared(SharedEventManagerInterface $events) { $events->attach('*', NotificationEvent::EVENT_NOTIFICATION_ADD, array($this, 'add'), 1); $events->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_DISPATCH, array($this, 'renderJSON'), -240); $events->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_DISPATCH, array($this, 'renderHTML'), -250); // Sometimes the Dispatch-Event is not reached, for instance with a route-direct // but also for Events, that are happening after the Dispatch $events->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_FINISH, array($this, 'renderHTML'), -250); return $this; }
/** * Attach shared listeners to the RestServiceModel. * * @param SharedEventManagerInterface $sharedEvents * @param ContainerInterface $container * @return void */ private function attachSharedListeners(SharedEventManagerInterface $sharedEvents, ContainerInterface $container) { $sharedEvents->attach(RestServiceModel::class, 'fetch', [DbConnectedRestServiceModel::class, 'onFetch']); $modules = $container->get('ModuleManager'); $loaded = $modules->getLoadedModules(false); if (!isset($loaded['ZF\\Apigility\\Doctrine\\Admin'])) { return; } // Wire Doctrine-Connected fetch listener $sharedEvents->attach(RestServiceModel::class, 'fetch', [DoctrineRestServiceModel::class, 'onFetch']); }
public function attachShared(SharedEventManagerInterface $events) { $class = 'Athene2\\Versioning\\Manager\\RepositoryManager'; // Looks like everything worked out fine! $events->attach($class, VersioningEvent::COMMIT, [$this, 'onCommit']); $events->attach($class, VersioningEvent::CHECKOUT, [$this, 'onCheckout']); $events->attach($class, VersioningEvent::REJECT, [$this, 'onReject']); // These events get triggered, when authorization was not granted. // $events->attach($class, VersioningEvent::COMMIT_UNAUTHORIZED, [$this, 'onCommitError']); // $events->attach($class, VersioningEvent::CHECKOUT_UNAUTHORIZED, [$this, 'onCheckoutError']); // $events->attach($class, VersioningEvent::REJECT_UNAUTHORIZED, [$this, 'onRejectError']); }
/** * @param SharedEventManagerInterface $events */ public function attachShared(SharedEventManagerInterface $events) { $classes = $this->cacheOptions->getListens(); foreach ($classes as $class => $options) { foreach ($options as $event => $invalidators) { $strategyManager = $this->strategyManager; $events->attach($class, $event, function (Event $e) use($class, $event, $invalidators, $strategyManager) { foreach ($invalidators as $invalidator) { $invalidator = $strategyManager->get($invalidator); $invalidator->invalidate($e, $class, $event); } }); } } }
public function attachListeners(SharedEventManagerInterface $sharedEventManager) { $sharedEventManager->attach('Omeka\\Form\\SiteSettingsForm', Event::SITE_SETTINGS_ADD_ELEMENTS, [$this, 'addSiteEnableCheckbox']); $sharedEventManager->attach('Omeka\\Form\\SiteSettingsForm', Event::SITE_SETTINGS_ADD_INPUT_FILTERS, [$this, 'addSiteSettingsFilters']); $sharedEventManager->attach('Omeka\\Controller\\Site\\Item', 'view.show.before', array($this, 'viewShowAfter')); $sharedEventManager->attach('Omeka\\Controller\\Site\\Page', 'view.show.after', array($this, 'viewShowAfter')); $sharedEventManager->attach('Omeka\\Controller\\Site\\Item', 'view.show.after', array($this, 'insertOpenGraphData')); $sharedEventManager->attach('Omeka\\Controller\\Site\\Index', 'view.show.after', array($this, 'insertOpenGraphData')); $sharedEventManager->attach('Omeka\\Controller\\Site\\Page', 'view.show.after', array($this, 'insertOpenGraphData')); }
/** * {@inheritDoc} */ public function attachListeners(SharedEventManagerInterface $sharedEventManager) { $sharedEventManager->attach('Zend\\View\\Helper\\Navigation\\AbstractHelper', 'isAllowed', [$this, 'navigationPageIsAllowed']); $sharedEventManager->attach('Omeka\\Entity\\Media', OmekaEvent::ENTITY_REMOVE_POST, [$this, 'deleteMediaFiles']); $sharedEventManager->attach('Omeka\\Api\\Representation\\MediaRepresentation', OmekaEvent::REP_RESOURCE_JSON, [$this, 'filterHtmlMediaJsonLd']); $sharedEventManager->attach('Omeka\\Api\\Representation\\MediaRepresentation', OmekaEvent::REP_RESOURCE_JSON, [$this, 'filterYoutubeMediaJsonLd']); $sharedEventManager->attach('Omeka\\Api\\Adapter\\MediaAdapter', [OmekaEvent::API_SEARCH_QUERY, OmekaEvent::API_FIND_QUERY], [$this, 'filterMedia']); $sharedEventManager->attach('Omeka\\Api\\Adapter\\SiteAdapter', [OmekaEvent::API_SEARCH_QUERY, OmekaEvent::API_FIND_QUERY], [$this, 'filterSites']); $sharedEventManager->attach(['Omeka\\Controller\\Admin\\Item', 'Omeka\\Controller\\Admin\\ItemSet', 'Omeka\\Controller\\Admin\\Media', 'Omeka\\Controller\\Site\\Item', 'Omeka\\Controller\\Site\\Media'], 'view.show.after', function (OmekaEvent $event) { $resource = $event->getTarget()->resource; echo $resource->embeddedJsonLd(); }); $sharedEventManager->attach(['Omeka\\Controller\\Admin\\Item', 'Omeka\\Controller\\Admin\\ItemSet', 'Omeka\\Controller\\Admin\\Media', 'Omeka\\Controller\\Site\\Item'], 'view.browse.after', function (OmekaEvent $event) { $resources = $event->getTarget()->resources; foreach ($resources as $resource) { echo $resource->embeddedJsonLd(); } }); }
/** * Get listeners for the currently triggered event. * * @param string $eventName * @return callable[] */ private function getListenersByEventName($eventName) { $listeners = array_merge_recursive(isset($this->events[$eventName]) ? $this->events[$eventName] : [], isset($this->events['*']) ? $this->events['*'] : [], $this->sharedManager ? $this->sharedManager->getListeners($this->identifiers, $eventName) : []); krsort($listeners, SORT_NUMERIC); $listenersForEvent = []; foreach ($listeners as $priority => $listenersByPriority) { foreach ($listenersByPriority as $listener) { // Performance note: after some testing, it appears that accumulating listeners and sending // them at the end of the method is FASTER than using generators (ie. yielding) $listenersForEvent[] = $listener; } } return $listenersForEvent; }
public function attachShared(\Zend\EventManager\SharedEventManagerInterface $events) { $class = $this->getMonitoredClass(); $events->attach($class, 'parent.change', [$this, 'onParentChange']); $events->attach($class, 'create', [$this, 'onCreate']); $events->attach($class, 'update', [$this, 'onUpdate']); $events->attach($class, 'associate', [$this, 'onAssociate']); $events->attach($class, 'dissociate', [$this, 'onDissociate']); }
/** * Attach listener to shared event manager. * * @param SharedEventManagerInterface $manager Shared event manager * * @return void */ public function attach(SharedEventManagerInterface $manager) { $manager->attach('VuFind\\Search', 'pre', [$this, 'onSearchPre']); $manager->attach('VuFind\\Search', 'post', [$this, 'onSearchPost']); }
/** * Attach listener to shared event manager. * * @param SharedEventManagerInterface $manager Shared event manager * * @return void */ public function attach(SharedEventManagerInterface $manager) { $manager->attach('VuFind\\Search', 'error', [$this, 'onSearchError']); }
public function attachShared(SharedEventManagerInterface $events) { $events->attach($this->getMonitoredClass(), 'create', [$this, 'onUpdate']); $events->attach($this->getMonitoredClass(), 'update', [$this, 'onUpdate']); }
public function attachListeners(SharedEventManagerInterface $sharedEventManager) { $sharedEventManager->attach('Omeka\\DataType\\Manager', 'service.registered_names', [$this, 'addVocabularyServices']); $sharedEventManager->attach('CustomVocab\\Entity\\CustomVocab', 'entity.remove.pre', [$this, 'setVocabTypeToDefaultState']); }
public function attachShared(SharedEventManagerInterface $events) { $events->attach($this->getMonitoredClass(), 'register', [$this, 'onRegister'], -1); }
/** * Attach event for backend * * @param Backend $backend */ public function attach(Backend $backend) { $this->backend = $backend; $this->eventsManager->attach('VuFind\\Search', 'pre', array($this, 'onSearchPre'), -100); }
/** * Reattach all problem listeners detached by detachProblemListeners(), if any. * * @param SharedEvents $sharedEvents Shared event manager * @param array $listeners Output of detachProblemListeners() * @return void */ protected function reattachProblemListeners(SharedEvents $sharedEvents, array $listeners) { foreach ($listeners as $id => $eventArray) { foreach ($eventArray as $eventName => $callbacks) { foreach ($callbacks as $current) { $sharedEvents->attach($id, $eventName, $current->getCallback(), $current->getMetadatum('priority')); } } } }
public function attachShared(SharedEventManagerInterface $events) { $mailForgotPassword = $this->getServiceManager()->get('Auth/Listener/MailForgotPassword'); $events->attach('Auth', AuthEvent::EVENT_AUTH_NEWPASSWORD, $mailForgotPassword, 10); return $this; }