本文整理汇总了PHP中Zend\EventManager\SharedEventManagerInterface::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP SharedEventManagerInterface::attach方法的具体用法?PHP SharedEventManagerInterface::attach怎么用?PHP SharedEventManagerInterface::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\SharedEventManagerInterface
的用法示例。
在下文中一共展示了SharedEventManagerInterface::attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attachShared
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);
}
示例2: attachShared
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']);
}
示例3: attachShared
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']);
}
示例4: attachShared
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']);
}
示例5: attachShared
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__;
}
示例6: attachShared
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;
}
示例7: attachSharedListeners
/**
* 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']);
}
示例8: attachShared
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']);
}
示例9: attachShared
/**
* @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;
}
示例10: attachShared
/**
* Attach listeners to an event manager
*
* @param EventManagerInterface $events
* @return void
*
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function attachShared(SharedEventManagerInterface $events)
{
$this->listeners[] = $events->attach('*', ImageEvent::POST_SUCCESS, [$this, 'postSuccess'], 1);
$this->listeners[] = $events->attach('*', ImageEvent::POST_UPLOAD, [$this, 'backupImage'], 1000);
$this->listeners[] = $events->attach('*', ImageEvent::POST_UPLOAD, [$this, 'resizeImage'], 500);
$this->listeners[] = $events->attach('*', ImageEvent::POST_UPLOAD, [$this, 'thumbnailImage'], 100);
$this->listeners[] = $events->attach('*', ImageEvent::PUT_SUCCESS, [$this, 'putSuccess'], 1);
$this->listeners[] = $events->attach('*', ImageEvent::DEL_SUCCESS, [$this, 'delSuccess'], 1);
$this->listeners[] = $events->attach('*', ImageEvent::DEL_FAILED, [$this, 'delFailed'], 1);
}
示例11: attachListeners
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'));
}
示例12: attachShared
/**
* @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);
}
});
}
}
}
示例13: attachListeners
/**
* {@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();
}
});
}
示例14: attach
/**
* Attach listener to shared event manager.
*
* @param SharedEventManagerInterface $manager Shared event manager
*
* @return void
*/
public function attach(SharedEventManagerInterface $manager)
{
$manager->attach('VuFind\\Search', Service::EVENT_PRE, [$this, 'onSearchPre']);
$manager->attach('VuFind\\Search', Service::EVENT_POST, [$this, 'onSearchPost']);
}
示例15: attachListeners
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']);
}