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


PHP EventInterface::stopPropagation方法代码示例

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


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

示例1: checkSignals

 /**
  * @param EventInterface $event
  */
 public function checkSignals(EventInterface $event)
 {
     pcntl_signal_dispatch();
     if ($this->shouldStop) {
         $event->stopPropagation();
     }
 }
开发者ID:CarsonF,项目名称:WhatsApi,代码行数:10,代码来源:PcntlListener.php

示例2: onDisconnect

 /**
  * Triggered on disconnect.
  *
  * @param EventInterface $event The triggered event
  */
 public function onDisconnect(EventInterface $event)
 {
     if (!$this->connected) {
         $event->stopPropagation(true);
     } else {
         $this->connected = false;
     }
 }
开发者ID:thomasvargiu,项目名称:pami-module,代码行数:13,代码来源:ConnectionStatusListener.php

示例3: onFailure

 /**
  * onFailure
  *
  * Event listener to handle unsuccessful authentication.
  *
  * @param EventInterface  $event  The authentication event.
  *
  * @return Request
  */
 public function onFailure(EventInterface $event)
 {
     /** @var  LoginControllerInterface $controller */
     $controller = $event->getTarget();
     //$controller->flashMessenger()->addErrorMessage('The username or password was incorrect.');
     $route = $controller->getRouteProvider()->getRoute('authentication.failure');
     $event->stopPropagation(true);
     return $controller->redirect()->toRoute($route);
 }
开发者ID:alex-patterson-webdev,项目名称:arp-auth,代码行数:18,代码来源:DefaultLoginStrategy.php

示例4: preFind

 /**
  * @param EventInterface $event
  */
 public function preFind(EventInterface $event)
 {
     if (!preg_match('/\\d$/', $this->cacheId)) {
         return;
         //The current route is a POST, do not cache new resources with this cache ID
     }
     if ($this->cache->contains($this->cacheId)) {
         $event->stopPropagation(true);
         return $this->cache->fetch($this->cacheId);
     }
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:14,代码来源:CacheListener.php

示例5: accept

 /**
  * Checks if the current page should be visible in the navigation menu.
  *
  * @param EventInterface $event
  * @return boolean
  */
 public function accept(EventInterface $event)
 {
     $event->stopPropagation();
     $accepted = true;
     $page = $event->getParam('page');
     $permission = $page->getPermission();
     if ($permission === '*') {
         return true;
     } elseif ($permission) {
         $accepted = $this->authService->isGranted($permission);
     }
     return $accepted;
 }
开发者ID:mhilker,项目名称:user,代码行数:19,代码来源:RbacListener.php

示例6: isAllowed

 public function isAllowed(EventInterface $event)
 {
     $target = $event->getTarget();
     if ($target instanceof \Zend\View\Helper\Navigation\AbstractHelper) {
         $page = $event->getParam('page');
         if (!$page instanceof AbstractPage) {
             return;
         }
         $permission = $page->getPermission();
         if (null === $permission) {
             return;
         }
         $event->stopPropagation();
         return $this->authorizationService->isGranted($permission);
     }
 }
开发者ID:zend-modules,项目名称:zfc-user-rbac-doctrine-orm,代码行数:16,代码来源:NavigationListener.php

示例7: redirect

 protected function redirect(EventInterface $e, $route)
 {
     $app = $e->getApplication();
     $sm = $app->getServiceManager();
     /** @var \Zend\Mvc\Router\Http\TreeRouteStack $route */
     $currentRoute = $app->getMvcEvent()->getRouteMatch()->getMatchedRouteName();
     if ($currentRoute == $route) {
         return false;
     }
     $matchedRoute = $sm->get('Router')->assemble(array(), array('name' => $route));
     $response = $e->getResponse();
     $response->getHeaders()->addHeaderLine('Location', $matchedRoute);
     $response->setStatusCode(302);
     $response->sendHeaders();
     $e->stopPropagation();
     return false;
 }
开发者ID:zf-hipsters,项目名称:authorize,代码行数:17,代码来源:Module.php

示例8: check

 /**
  * Check if ssl is forced or not
  *
  * @param EventInterface $event Mvc event
  *
  * @return null|Zend\Http\PhpEnvironment\Response
  */
 public function check(EventInterface $event)
 {
     $coreConfig = $event->getApplication()->getServiceManager()->get('CoreConfig');
     $matchedRouteName = $event->getRouteMatch()->getMatchedRouteName();
     $request = $event->getRequest();
     $uri = $request->getUri();
     if ($matchedRouteName === 'cms') {
         if ($uri->getScheme() === 'https' or $coreConfig->getValue('force_frontend_ssl')) {
             $newUri = new Uri($coreConfig->getValue('secure_frontend_base_path'));
             $newUri->setScheme('https');
         } else {
             $newUri = new Uri($coreConfig->getValue('unsecure_frontend_base_path'));
         }
     } else {
         if ($uri->getScheme() === 'https' or $coreConfig->getValue('force_backend_ssl')) {
             $newUri = new Uri($coreConfig->getValue('secure_backend_base_path'));
             $newUri->setScheme('https');
         } else {
             $newUri = new Uri($coreConfig->getValue('unsecure_backend_base_path'));
         }
     }
     if (!empty($newUri) and $newUri->isValid() and ($newUri->getHost() != '' and $uri->getHost() != $newUri->getHost()) or $newUri->getScheme() != '' and $uri->getScheme() != $newUri->getScheme()) {
         $uri->setPort($newUri->getPort());
         if ($newUri->getHost() != '') {
             $uri->setHost($newUri->getHost());
         }
         if ($newUri->getScheme() != '') {
             $uri->setScheme($newUri->getScheme());
         }
         $response = $event->getResponse();
         $response->setStatusCode(302);
         $response->getHeaders()->addHeaderLine('Location', $request->getUri());
         $event->stopPropagation();
         return $response;
     }
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:43,代码来源:SslListener.php

示例9: onDoctrineLoadCliPost

 /**
  * Останавливаем обработку событий
  *
  * @param EventInterface $event
  */
 public function onDoctrineLoadCliPost(EventInterface $event)
 {
     $event->stopPropagation(true);
 }
开发者ID:old-town,项目名称:zf2-test-toolkit,代码行数:9,代码来源:StopDoctrineLoadCliPostEventListener.php

示例10: triggerListeners

 /**
  * Trigger listeners
  *
  * Actual functionality for triggering listeners, to which trigger() delegate.
  *
  * @param  EventInterface $event
  * @param  null|callable $callback
  * @return ResponseCollection
  */
 protected function triggerListeners(EventInterface $event, callable $callback = null)
 {
     $name = $event->getName();
     if (empty($name)) {
         throw new Exception\RuntimeException('Event is missing a name; cannot trigger!');
     }
     // Initial value of stop propagation flag should be false
     $event->stopPropagation(false);
     $responses = new ResponseCollection();
     foreach ($this->getListenersByEventName($name) as $listener) {
         $response = $listener($event);
         $responses->push($response);
         // If the event was asked to stop propagating, do so
         if ($event->propagationIsStopped()) {
             $responses->setStopped(true);
             break;
         }
         // If the result causes our validation callback to return true,
         // stop propagation
         if ($callback && $callback($response)) {
             $responses->setStopped(true);
             break;
         }
     }
     return $responses;
 }
开发者ID:John-Eddy,项目名称:ProjetCastor,代码行数:35,代码来源:EventManager.php


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