/** * @since 1.0 * * {@inheritDoc} * * @throws RuntimeException */ public function addListenerCollection(EventListenerCollection $listenerCollection) { $collection = $listenerCollection->getCollection(); if (!is_array($collection) && !$collection instanceof Traversable) { throw new RuntimeException("Expected a traversable object"); } foreach ($collection as $event => $listeners) { foreach ($listeners as $listener) { $this->addListener($event, $listener); } } }
private function addListenersToCollection() { $this->eventListenerCollection->registerCallback('exporter.reset', function () { Exporter::getInstance()->clear(); }); $this->eventListenerCollection->registerCallback('property.spec.change', function ($dispatchContext) { $subject = $dispatchContext->get('subject'); $updateDispatcherJob = ApplicationFactory::getInstance()->newJobFactory()->newUpdateDispatcherJob($subject->getTitle()); $updateDispatcherJob->run(); Exporter::getInstance()->resetCacheFor($subject); $dispatchContext->set('propagationstop', true); }); return $this->eventListenerCollection; }
private function registerStateChangeEvents() { /** * Emitted during PropertySpecificationChangeNotifier::notifyDispatcher */ $this->eventListenerCollection->registerCallback('property.specification.change', function ($dispatchContext) { $applicationFactory = ApplicationFactory::getInstance(); $subject = $dispatchContext->get('subject'); $updateDispatcherJob = $applicationFactory->newJobFactory()->newUpdateDispatcherJob($subject->getTitle()); $updateDispatcherJob->run(); Exporter::getInstance()->resetCacheBy($subject); $applicationFactory->getPropertySpecificationLookup()->resetCacheBy($subject); $dispatchContext->set('propagationstop', true); }); /** * Emitted during Store::updateData */ $this->eventListenerCollection->registerCallback('on.before.semanticdata.update.complete', function ($dispatchContext) { $subject = $dispatchContext->get('subject'); $hash = $subject->getHash(); $applicationFactory = ApplicationFactory::getInstance(); $poolCache = $applicationFactory->getInMemoryPoolCache()->getPoolCacheFor('store.redirectTarget.lookup'); $poolCache->delete($hash); $dispatchContext->set('propagationstop', true); }); /** * Emitted during Store::updateData */ $this->eventListenerCollection->registerCallback('on.after.semanticdata.update.complete', function ($dispatchContext) { $applicationFactory = ApplicationFactory::getInstance(); $subject = $dispatchContext->get('subject'); $pageUpdater = $applicationFactory->newMwCollaboratorFactory()->newPageUpdater(); if ($GLOBALS['smwgAutoRefreshSubject'] && $pageUpdater->canUpdate()) { $pageUpdater->addPage($subject->getTitle()); $deferredCallableUpdate = $applicationFactory->newDeferredCallableUpdate(function () use($pageUpdater) { $pageUpdater->doPurgeParserCache(); $pageUpdater->doPurgeHtmlCache(); }); $deferredCallableUpdate->setOrigin('Event on.after.semanticdata.update.complete doPurgeParserCache for ' . $subject->getHash()); $deferredCallableUpdate->pushToUpdateQueue(); } $dispatchContext->set('propagationstop', true); }); }
private function addListenersToCollection() { $this->eventListenerCollection->registerCallback('factbox.cache.delete', function ($dispatchContext) { $title = $dispatchContext->get('title'); $cache = ApplicationFactory::getInstance()->getCache(); $cache->delete(ApplicationFactory::getInstance()->newCacheFactory()->getFactboxCacheKey($title->getArticleID())); }); $this->eventListenerCollection->registerCallback('exporter.reset', function () { Exporter::getInstance()->clear(); }); $this->eventListenerCollection->registerCallback('query.comparator.reset', function () { QueryComparator::getInstance()->clear(); }); $this->eventListenerCollection->registerCallback('property.spec.change', function ($dispatchContext) { $subject = $dispatchContext->get('subject'); $updateDispatcherJob = ApplicationFactory::getInstance()->newJobFactory()->newUpdateDispatcherJob($subject->getTitle()); $updateDispatcherJob->run(); Exporter::getInstance()->resetCacheFor($subject); $dispatchContext->set('propagationstop', true); }); return $this->eventListenerCollection; }