本文整理匯總了PHP中Zend\EventManager\EventManagerInterface::attachAggregate方法的典型用法代碼示例。如果您正苦於以下問題:PHP EventManagerInterface::attachAggregate方法的具體用法?PHP EventManagerInterface::attachAggregate怎麽用?PHP EventManagerInterface::attachAggregate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\EventManager\EventManagerInterface
的用法示例。
在下文中一共展示了EventManagerInterface::attachAggregate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: attachWorkerListeners
/**
* @param EventManagerInterface $eventManager
* @param StrategyPluginManager $listenerPluginManager
* @param array $strategyConfig
* @throws RuntimeException
*/
protected function attachWorkerListeners(EventManagerInterface $eventManager, StrategyPluginManager $listenerPluginManager, array $strategyConfig = [])
{
foreach ($strategyConfig as $strategy => $options) {
// no options given, name stored as value
if (is_numeric($strategy) && is_string($options)) {
$strategy = $options;
$options = [];
}
if (!is_string($strategy) || !is_array($options)) {
continue;
}
$priority = null;
if (isset($options['priority'])) {
$priority = $options['priority'];
unset($options['priority']);
}
$listener = $listenerPluginManager->get($strategy, $options);
if (!is_null($priority)) {
$eventManager->attachAggregate($listener, $priority);
} else {
$eventManager->attachAggregate($listener);
}
}
if (!in_array(WorkerEvent::EVENT_BOOTSTRAP, $eventManager->getEvents())) {
throw new RuntimeException(sprintf("No worker strategy has been registered to respond to the '%s' event.", WorkerEvent::EVENT_BOOTSTRAP));
}
}
示例2: attach
/**
* Attach one or more listeners
*
* @param EventManagerInterface $events
* @return DefaultListenerAggregate
*/
public function attach(EventManagerInterface $events)
{
$options = $this->getOptions();
$configListener = $this->getConfigListener();
$locatorRegistrationListener = new LocatorRegistrationListener($options);
$moduleAutoloader = new ModuleAutoloader($options->getModulePaths());
$this->listeners[] = $events->attach('loadModules.pre', array($moduleAutoloader, 'register'), 1000);
$this->listeners[] = $events->attach('loadModule.resolve', new ModuleResolverListener(), 1000);
$this->listeners[] = $events->attach('loadModule', new AutoloaderListener($options), 2000);
$this->listeners[] = $events->attach('loadModule', new InitTrigger($options), 1000);
$this->listeners[] = $events->attach('loadModule', new OnBootstrapListener($options), 1000);
$this->listeners[] = $events->attachAggregate($locatorRegistrationListener);
$this->listeners[] = $events->attachAggregate($configListener);
return $this;
}
示例3: init
/**
* Registers listeners if enabled.
*
* @return self
*/
public function init()
{
if ($this->options->isEnabled()) {
if ($this->options->canFlushEarly()) {
$this->eventManager->attachAggregate($this->serviceLocator->get('ZDT_FlushListener'));
}
if ($this->options->isStrict() && $this->report->hasErrors()) {
throw new Exception\InvalidOptionException(implode(' ', $this->report->getErrors()));
}
$this->eventManager->attachAggregate($this->serviceLocator->get('ZDT_ProfileListener'));
$this->registerVerbose()->registerToolbar();
if ($this->options->isStrict() && $this->report->hasErrors()) {
throw new Exception\ProfilerException(implode(' ', $this->report->getErrors()));
}
}
return $this;
}
示例4: attach
public function attach(ListenerAggregateInterface $listener)
{
$this->events->attachAggregate($listener);
}
示例5: loadEvent
protected function loadEvent(EventManagerInterface $eventManager)
{
$eventManager->attachAggregate(new AuthorizationListenerAggregate());
}
示例6: injectDefaultListeners
/**
* @param EventManagerInterface $eventManager
*/
protected function injectDefaultListeners(EventManagerInterface $eventManager)
{
$eventManager->attachAggregate(new Plugin\Message());
$eventManager->attachAggregate(new Feature\Executor());
$eventManager->attachAggregate(new Feature\Notifications());
}