コード例 #1
0
ファイル: TokenListener.php プロジェクト: webpants/YAWIK
 /**
  * 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;
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function detachShared(SharedEventManagerInterface $events)
 {
     foreach ($this->listeners as $listener) {
         $events->detach(self::EVENT_IDENTIFIER, $listener);
     }
     unset($this->listeners);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 /**
  * @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]);
         }
     }
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function detachShared(SharedEventManagerInterface $events)
 {
     foreach ($this->listeners as $id => $listener) {
         if ($events->detach($id, $listener)) {
             unset($this->listeners[$id]);
         }
     }
 }
コード例 #6
0
 /**
  * @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;
 }
コード例 #7
0
 /**
  * @inheritdoc
  */
 public function detachShared(SharedEventManagerInterface $events)
 {
     foreach ($this->listeners as $index => $listener) {
         if ($events->detach(AclService::class, $listener)) {
             unset($this->listeners[$index]);
         }
     }
 }
コード例 #8
0
 public function detachShared(SharedEventManagerInterface $events)
 {
     foreach ($this->sharedListeners as $index => $listener) {
         if ($events->detach($this->eventIdentifier, $listener)) {
             unset($this->sharedListeners[$index]);
         }
     }
 }
コード例 #9
0
 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']);
 }
コード例 #10
0
 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']);
 }
コード例 #11
0
 /**
  * @inheritdoc
  */
 public function detachShared(SharedEventManagerInterface $events)
 {
     foreach ($this->listeners as $index => $listener) {
         if ($events->detach(AbstractActionController::class, $listener)) {
             unset($this->listeners[$index]);
         }
     }
 }
コード例 #12
0
ファイル: IssueCacheListener.php プロジェクト: av4tar/sheti
 public function detachShared(SharedEventManagerInterface $events)
 {
     foreach ($this->listeners as $index => $callback) {
         if ($events->dettach($callback)) {
             unset($this->listeners[$index]);
         }
     }
 }
コード例 #13
0
 public function detachShared(\Zend\EventManager\SharedEventManagerInterface $events)
 {
     foreach ($this->listeners as $index => $listener) {
         if ($events->detach($this->getMonitoredClass(), $listener)) {
             unset($this->listeners[$index]);
         }
     }
 }
コード例 #14
0
 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__;
 }
コード例 #15
0
 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;
 }
コード例 #16
0
 /**
  * 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']);
 }
コード例 #17
0
 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']);
 }
コード例 #18
0
 /**
  * @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);
                 }
             });
         }
     }
 }
コード例 #19
0
ファイル: Module.php プロジェクト: omeka-s-modules/Sharing
 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'));
 }
コード例 #20
0
ファイル: Module.php プロジェクト: patrova/omeka-s
 /**
  * {@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();
         }
     });
 }
コード例 #21
0
 /**
  * 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;
 }
コード例 #22
0
 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']);
 }
コード例 #23
0
 /**
  * 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']);
 }
コード例 #24
0
 /**
  * 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']);
 }
コード例 #25
0
 public function attachShared(SharedEventManagerInterface $events)
 {
     $events->attach($this->getMonitoredClass(), 'create', [$this, 'onUpdate']);
     $events->attach($this->getMonitoredClass(), 'update', [$this, 'onUpdate']);
 }
コード例 #26
0
 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']);
 }
コード例 #27
0
 public function attachShared(SharedEventManagerInterface $events)
 {
     $events->attach($this->getMonitoredClass(), 'register', [$this, 'onRegister'], -1);
 }
コード例 #28
0
ファイル: SolrConfigurator.php プロジェクト: htw-pk15/vufind
 /**
  * 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);
 }
コード例 #29
0
 /**
  * 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'));
             }
         }
     }
 }
コード例 #30
0
 public function attachShared(SharedEventManagerInterface $events)
 {
     $mailForgotPassword = $this->getServiceManager()->get('Auth/Listener/MailForgotPassword');
     $events->attach('Auth', AuthEvent::EVENT_AUTH_NEWPASSWORD, $mailForgotPassword, 10);
     return $this;
 }