本文整理汇总了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();
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例9: onDoctrineLoadCliPost
/**
* Останавливаем обработку событий
*
* @param EventInterface $event
*/
public function onDoctrineLoadCliPost(EventInterface $event)
{
$event->stopPropagation(true);
}
示例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;
}