当前位置: 首页>>代码示例>>PHP>>正文


PHP EventDispatcherInterface::getListeners方法代码示例

本文整理汇总了PHP中Symfony\Component\EventDispatcher\EventDispatcherInterface::getListeners方法的典型用法代码示例。如果您正苦于以下问题:PHP EventDispatcherInterface::getListeners方法的具体用法?PHP EventDispatcherInterface::getListeners怎么用?PHP EventDispatcherInterface::getListeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\EventDispatcher\EventDispatcherInterface的用法示例。


在下文中一共展示了EventDispatcherInterface::getListeners方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispatch

 /**
  * {@inheritDoc}
  *
  * @param string $event The name of the Event which should be dispatched
  * @param array $options The options that should get passed to the callback
  */
 public function dispatch($event, $options)
 {
     $listeners = $this->eventDispatcher->getListeners($event);
     foreach ($listeners as $listener) {
         call_user_func($listener, $options);
     }
 }
开发者ID:phpab,项目名称:phpab,代码行数:13,代码来源:SymfonyBridge.php

示例2: dispatch

 /**
  * {@inheritdoc}
  */
 public function dispatch(EventInterface $event)
 {
     $listeners = $this->eventDispatcher->getListeners($event->getName());
     foreach ($listeners as $listener) {
         if (count($listener[0]) === 2) {
             $listener = $listener[0];
         }
         call_user_func($listener, $event);
     }
 }
开发者ID:nunodotferreira,项目名称:ApiGen,代码行数:13,代码来源:SymfonyEventDispatcher.php

示例3: getInternalEventListeners

 /**
  * returns all the listeners in the app that are listening to domain messages
  *
  * @return array returns array of listener details (name and callback reference) by event key
  *
  */
 public function getInternalEventListeners()
 {
     $all_listeners = $this->dispatcher->getListeners();
     $domain_listeners = array();
     $prefix = $this->getEventPrefix();
     $prefix_length = strlen($prefix);
     foreach ($all_listeners as $event_name => $listener_by_event) {
         // if this event key is a domain message
         if (substr($event_name, 0, $prefix_length) === $prefix) {
             $domain_listeners[$event_name] = $listener_by_event;
         }
     }
     return $domain_listeners;
 }
开发者ID:ktsharp,项目名称:EcentriaAPIEventsBundle,代码行数:20,代码来源:MessageDispatcher.php

示例4: activate

 /**
  * Activate cross processes tunnel.
  * NB: Should be called only in child process!
  * Removes all current registered listeners.
  */
 public function activate()
 {
     foreach ($this->dispatcher->getListeners() as $event => $listeners) {
         foreach ($listeners as $listener) {
             $this->dispatcher->removeListener($event, $listener);
         }
     }
     foreach ($this->events as $event) {
         $this->dispatcher->addListener($event, [$this, 'onEvent']);
     }
     foreach ($this->sockets as $socket) {
         fclose($socket);
     }
     fclose($this->childSocket);
 }
开发者ID:komex,项目名称:unteist,代码行数:20,代码来源:Connector.php

示例5: getEventListeners

 /**
  * @param string $eventName
  *
  * @return array
  */
 protected function getEventListeners($eventName)
 {
     $results = array();
     foreach ($this->eventDispatcher->getListeners($eventName) as $listener) {
         if (is_object($listener[0])) {
             $results[] = get_class($listener[0]);
         } elseif (is_string($listener[0])) {
             $results[] = $listener[0];
         } elseif ($listener instanceof \Closure) {
             $results[] = '{closure}()';
         } else {
             $results[] = 'Unknown type!';
         }
     }
     return $results;
 }
开发者ID:karousn,项目名称:SonataBlockBundle,代码行数:21,代码来源:BlockHelper.php

示例6: describeEventDispatcherListeners

 /**
  * {@inheritdoc}
  */
 protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array())
 {
     $event = array_key_exists('event', $options) ? $options['event'] : null;
     $title = 'Registered listeners';
     if (null !== $event) {
         $title .= sprintf(' for event `%s` ordered by descending priority', $event);
     }
     $this->write(sprintf('# %s', $title) . "\n");
     $registeredListeners = $eventDispatcher->getListeners($event);
     if (null !== $event) {
         foreach ($registeredListeners as $order => $listener) {
             $this->write("\n" . sprintf('## Listener %d', $order + 1) . "\n");
             $this->describeCallable($listener);
         }
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             $this->write("\n" . sprintf('## %s', $eventListened) . "\n");
             foreach ($eventListeners as $order => $eventListener) {
                 $this->write("\n" . sprintf('### Listener %d', $order + 1) . "\n");
                 $this->describeCallable($eventListener);
             }
         }
     }
 }
开发者ID:makhloufi-lounis,项目名称:tuto_symfony,代码行数:28,代码来源:MarkdownDescriptor.php

示例7: describeEventDispatcherListeners

 /**
  * {@inheritdoc}
  */
 protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array())
 {
     $event = array_key_exists('event', $options) ? $options['event'] : null;
     if (null !== $event) {
         $title = sprintf('Registered Listeners for "%s" Event', $event);
     } else {
         $title = 'Registered Listeners Grouped by Event';
     }
     $options['output']->title($title);
     $registeredListeners = $eventDispatcher->getListeners($event);
     if (null !== $event) {
         $this->renderEventListenerTable($eventDispatcher, $event, $registeredListeners, $options['output']);
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             $options['output']->section(sprintf('"%s" event', $eventListened));
             $this->renderEventListenerTable($eventDispatcher, $eventListened, $eventListeners, $options['output']);
         }
     }
 }
开发者ID:robhaverkort,项目名称:belasting,代码行数:23,代码来源:TextDescriptor.php

示例8: getEventDispatcherListenersData

 /**
  * @param EventDispatcherInterface $eventDispatcher
  * @param string|null              $event
  *
  * @return array
  */
 private function getEventDispatcherListenersData(EventDispatcherInterface $eventDispatcher, $event = null)
 {
     $data = array();
     $registeredListeners = $eventDispatcher->getListeners($event);
     if (null !== $event) {
         foreach ($registeredListeners as $listener) {
             $l = $this->getCallableData($listener);
             $l['priority'] = $eventDispatcher->getListenerPriority($event, $listener);
             $data[] = $l;
         }
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             foreach ($eventListeners as $eventListener) {
                 $l = $this->getCallableData($eventListener);
                 $l['priority'] = $eventDispatcher->getListenerPriority($eventListened, $eventListener);
                 $data[$eventListened][] = $l;
             }
         }
     }
     return $data;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:28,代码来源:JsonDescriptor.php

示例9: flushHandlers

 /**
  * Flush handlers.
  *
  * Clears all handlers.
  *
  * @return void
  */
 public function flushHandlers()
 {
     foreach ($this->dispatcher->getListeners() as $eventName => $listener) {
         $this->dispatcher->removeListener($eventName, $listener);
     }
 }
开发者ID:rmaiwald,项目名称:core,代码行数:13,代码来源:HookDispatcher.php

示例10: getEventDispatcherListenersDocument

 /**
  * @param EventDispatcherInterface  $eventDispatcher
  * @param string|null               $event
  *
  * @return \DOMDocument
  */
 private function getEventDispatcherListenersDocument(EventDispatcherInterface $eventDispatcher, $event = null)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($eventDispatcherXML = $dom->createElement('event-dispatcher'));
     $registeredListeners = $eventDispatcher->getListeners($event);
     if (null !== $event) {
         foreach ($registeredListeners as $listener) {
             $callableXML = $this->getCallableDocument($listener);
             $eventDispatcherXML->appendChild($eventDispatcherXML->ownerDocument->importNode($callableXML->childNodes->item(0), true));
         }
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             $eventDispatcherXML->appendChild($eventXML = $dom->createElement('event'));
             $eventXML->setAttribute('name', $eventListened);
             foreach ($eventListeners as $eventListener) {
                 $callableXML = $this->getCallableDocument($eventListener);
                 $eventXML->appendChild($eventXML->ownerDocument->importNode($callableXML->childNodes->item(0), true));
             }
         }
     }
     return $dom;
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:29,代码来源:XmlDescriptor.php

示例11: describeEventDispatcherListeners

 /**
  * {@inheritdoc}
  */
 protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array())
 {
     $event = array_key_exists('event', $options) ? $options['event'] : null;
     $label = 'Registered listeners';
     if (null !== $event) {
         $label .= sprintf(' for event <info>%s</info>', $event);
     } else {
         $label .= ' by event';
     }
     $this->writeText($this->formatSection('event_dispatcher', $label) . "\n", $options);
     $registeredListeners = $eventDispatcher->getListeners($event);
     if (null !== $event) {
         $this->writeText("\n");
         $table = new Table($this->getOutput());
         $table->getStyle()->setCellHeaderFormat('%s');
         $table->setHeaders(array('Order', 'Callable'));
         foreach ($registeredListeners as $order => $listener) {
             $table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($listener)));
         }
         $this->renderTable($table, true);
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             $this->writeText(sprintf("\n<info>[Event]</info> %s\n", $eventListened), $options);
             $table = new Table($this->getOutput());
             $table->getStyle()->setCellHeaderFormat('%s');
             $table->setHeaders(array('Order', 'Callable'));
             foreach ($eventListeners as $order => $eventListener) {
                 $table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($eventListener)));
             }
             $this->renderTable($table, true);
         }
     }
 }
开发者ID:Chaireeee,项目名称:chaireeee,代码行数:37,代码来源:TextDescriptor.php

示例12: describeEventDispatcherListeners

 /**
  * Returns an human readable description of a collection of event listeners
  * in console
  *
  * @param OutputInterface $output
  * @param EventDispatcherInterface $eventDispatcher
  * @param array $options the Console input options
  */
 protected function describeEventDispatcherListeners(OutputInterface $output, EventDispatcherInterface $eventDispatcher, array $options)
 {
     $event = array_key_exists('event', $options) ? $options['event'] : null;
     $label = 'Registered listeners';
     if (null !== $event) {
         $label .= sprintf(' for event <info>%s</info>', $event);
     } else {
         $label .= ' by event';
     }
     $registeredListeners = $eventDispatcher->getListeners($event, true);
     if (null !== $event) {
         $output->writeln($label);
         $output->writeln(sprintf("\n<info>[Event]</info> %s\n", $event));
         $this->renderTable($output, $registeredListeners);
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             $output->writeln(sprintf("\n<info>[Event]</info> %s\n", $eventListened));
             krsort($eventListeners);
             $this->renderTable($output, $eventListeners);
         }
     }
 }
开发者ID:backbee,项目名称:debug-bundle,代码行数:31,代码来源:DebugEventDispatcherCommand.php

示例13: getListeners

 /**
  * @inheritdoc
  */
 public function getListeners($eventName)
 {
     return $this->dispatcher->getListeners($eventName);
 }
开发者ID:ldaptools,项目名称:ldaptools,代码行数:7,代码来源:SymfonyEventDispatcher.php

示例14: getListeners

 /**
  * Gets the listeners of a specific event or all listeners.
  *
  * @param string $eventName The name of the event.
  *
  * @return array The event listeners for the specified event, or all event listeners by event name
  */
 public function getListeners($eventName = null)
 {
     return $this->realDispatcher->getListeners($eventName);
 }
开发者ID:cyberspectrum,项目名称:contao-debugger,代码行数:11,代码来源:DebuggedEventDispatcher.php

示例15: describeEventDispatcherListeners

 /**
  * {@inheritdoc}
  */
 protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array())
 {
     $event = array_key_exists('event', $options) ? $options['event'] : null;
     $label = 'Registered listeners';
     if (null !== $event) {
         $label .= sprintf(' for event <info>%s</info>', $event);
     } else {
         $label .= ' by event';
     }
     $this->writeText($this->formatSection('event_dispatcher', $label) . "\n", $options);
     $registeredListeners = $eventDispatcher->getListeners($event, true);
     if (null !== $event) {
         $this->writeText("\n");
         $this->renderEventListenerTable($registeredListeners);
     } else {
         ksort($registeredListeners);
         foreach ($registeredListeners as $eventListened => $eventListeners) {
             $this->writeText(sprintf("\n<info>[Event]</info> %s\n", $eventListened), $options);
             $this->renderEventListenerTable($eventListeners);
         }
     }
 }
开发者ID:romankd,项目名称:symfony,代码行数:25,代码来源:TextDescriptor.php


注:本文中的Symfony\Component\EventDispatcher\EventDispatcherInterface::getListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。