本文整理汇总了PHP中Symfony\Component\EventDispatcher\EventDispatcherInterface::removeListener方法的典型用法代码示例。如果您正苦于以下问题:PHP EventDispatcherInterface::removeListener方法的具体用法?PHP EventDispatcherInterface::removeListener怎么用?PHP EventDispatcherInterface::removeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\EventDispatcherInterface
的用法示例。
在下文中一共展示了EventDispatcherInterface::removeListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGrid
/**
* @ActivityListQueryDesigner $queryDesigner
*
* @return DatagridInterface
*/
public function createGrid(ActivityListQueryDesigner $source)
{
$this->datagridConfigurationBuilder->setGridName('related-activity');
$this->datagridConfigurationBuilder->setSource($source);
$config = $this->datagridConfigurationBuilder->getConfiguration();
$stopPropagationListener = function (Event $e) {
$e->stopPropagation();
};
$this->eventDispatcher->addListener(BuildBefore::NAME, $stopPropagationListener, 255);
$grid = $this->gridBuilderLink->getService()->build($config, new ParameterBag());
$this->eventDispatcher->removeListener(BuildBefore::NAME, $stopPropagationListener);
return $grid;
}
示例2: detachEvents
public function detachEvents()
{
foreach ($this->attachedEvents as $eventInfo) {
$this->eventDispatcher->removeListener($eventInfo['key'], $eventInfo['callback']);
}
$this->attachedEvents = [];
}
示例3: removeEventListener
/**
* Removes an event listener for the given event name.
*
* @param string $eventName The event name.
* @param callable $listener The callback to remove.
*
* @return static The current instance.
*
* @see EventDispatcherInterface::removeListener()
*/
public function removeEventListener($eventName, $listener)
{
if (!$this->dispatcher) {
$this->dispatcher = new EventDispatcher();
}
$this->dispatcher->removeListener($eventName, $listener);
return $this;
}
示例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);
}
示例5: __invoke
public function __invoke(FilterResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$request = $event->getRequest();
$response = $event->getResponse();
$session = $this->getSession();
/** @var ApiOauthToken $token */
$token = $session->get('token');
$this->getApiLogManipulator()->create($token->getAccount(), $request, $response);
$this->getApiOAuthTokenManipulator()->setLastUsed($token, new \DateTime());
$session->set('token', null);
if (null !== $this->getAuthenticator()->getUser()) {
$this->getAuthenticator()->closeAccount();
}
$dispatcher->removeListener($eventName, $this);
}
示例6: unregister
/**
* Unregisters the dispatcher.
*
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
*/
public function unregister(EventDispatcherInterface $dispatcher)
{
$dispatcher->removeListener(KernelEvents::EXCEPTION, array($this, 'onKernelException'));
}
示例7: flushHandlers
/**
* Flush handlers.
*
* Clears all handlers.
*
* @return void
*/
public function flushHandlers()
{
foreach ($this->dispatcher->getListeners() as $eventName => $listener) {
$this->dispatcher->removeListener($eventName, $listener);
}
}
示例8: removeListener
/**
* @inheritdoc
*/
public function removeListener($eventName, callable $listener)
{
$this->dispatcher->removeListener($eventName, $listener);
}
示例9: removeListener
/**
* Removes an event listener from the specified events.
*
* @param string|array $eventName The event(s) to remove a listener from.
*
* @param callable $listener The listener to remove.
*
* @return void
*/
public function removeListener($eventName, $listener)
{
$this->realDispatcher->removeListener($eventName, $listener);
}
示例10: removeListener
/**
* {@inheritdoc}
*/
public function removeListener($eventName, $listener)
{
return $this->dispatcher->removeListener($eventName, $listener);
}
示例11: removeListener
/**
* Removes an event listener from the specified events.
*
* @param string $eventName The event to remove a listener from
* @param callable $listenerToBeRemoved The listener to remove
*/
public function removeListener($eventName, $listenerToBeRemoved)
{
$this->symfonyDispatcher->removeListener($eventName, $listenerToBeRemoved);
}
示例12: configure
/**
* Configures the error handler.
*
* @param Event|null $event The triggering event
* @param string|null $eventName The triggering event name
* @param EventDispatcherInterface|null $eventDispatcher The dispatcher used to trigger $event
*/
public function configure(Event $event = null, $eventName = null, EventDispatcherInterface $eventDispatcher = null)
{
if (null !== $eventDispatcher) {
foreach (array_keys(static::getSubscribedEvents()) as $name) {
$eventDispatcher->removeListener($name, array($this, 'configure'));
}
}
$handler = set_error_handler('var_dump', 0);
$handler = is_array($handler) ? $handler[0] : null;
restore_error_handler();
if ($handler instanceof ErrorHandler) {
if ($this->logger) {
$handler->setDefaultLogger($this->logger, $this->levels);
if (is_array($this->levels)) {
$scream = 0;
foreach ($this->levels as $type => $log) {
$scream |= $type;
}
} else {
$scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels;
}
if ($this->scream) {
$handler->screamAt($scream);
}
$this->logger = $this->levels = null;
}
if (null !== $this->throwAt) {
$handler->throwAt($this->throwAt, true);
}
}
if (!$this->exceptionHandler) {
if ($event instanceof KernelEvent) {
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
} elseif ($event instanceof ConsoleEvent && ($app = $event->getCommand()->getApplication())) {
$output = $event->getOutput();
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}
$this->exceptionHandler = function ($e) use($app, $output) {
$app->renderException($e, $output);
};
}
}
if ($this->exceptionHandler) {
$handler = set_exception_handler('var_dump');
$handler = is_array($handler) ? $handler[0] : null;
restore_exception_handler();
if ($handler instanceof ErrorHandler) {
$h = $handler->setExceptionHandler('var_dump') ?: $this->exceptionHandler;
$handler->setExceptionHandler($h);
$handler = is_array($h) ? $h[0] : null;
}
if ($handler instanceof ExceptionHandler) {
$handler->setHandler($this->exceptionHandler);
if (null !== $this->fileLinkFormat) {
$handler->setFileLinkFormat($this->fileLinkFormat);
}
}
$this->exceptionHandler = null;
}
}
示例13: __invoke
/**
* Invoke the handler.
*
* @param Event $event The event.
*
* @param string $eventName The event name.
*
* @param EventDispatcherInterface $dispatcher The dispatcher.
*
* @return void
*/
public function __invoke(Event $event, $eventName, $dispatcher)
{
$dispatcher->removeListener($eventName, $this);
call_user_func($this->handler, $event, $eventName, $dispatcher);
}