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


PHP GenericEvent::stopPropagation方法代码示例

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


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

示例1:

 function it_is_triggered_pre_delete(GenericEvent $event, CustomerInterface $customer, FlashBagInterface $flashBag, $session)
 {
     $event->getSubject()->willReturn($customer);
     $customer->getEmail()->willReturn('sylius@example.com');
     $session->getFlashBag()->willReturn($flashBag);
     $flashBag->add("error", "sylius_demo.account.prevent_delete")->shouldBeCalled();
     $event->stopPropagation()->shouldBeCalled();
     $this->preDelete($event);
 }
开发者ID:Zales0123,项目名称:SyliusDemo,代码行数:9,代码来源:AdminDeleteListenerSpec.php

示例2: checkDefaultGroup

 /**
  * Check if the current user group is the default group.
  *
  * @param GenericEvent $event
  *
  * @throws \Exception
  */
 protected function checkDefaultGroup(GenericEvent $event)
 {
     /** @var Group $group */
     $group = $event->getSubject();
     if (strtolower(User::GROUP_DEFAULT) === strtolower($group->getName())) {
         $event->stopPropagation();
         throw new \Exception(sprintf('The default group "%s" can not be updated.', $group->getName()));
     }
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:16,代码来源:GroupSubscriber.php

示例3: preDelete

 /**
  * @param GenericEvent $event
  */
 public function preDelete(GenericEvent $event)
 {
     if (!($subject = $event->getSubject()) instanceof CustomerInterface) {
         throw new UnexpectedTypeException($subject, 'Sylius\\Component\\Core\\Model\\CustomerInterface');
     }
     if ('sylius@example.com' === $subject->getEmail()) {
         $this->session->getFlashBag()->add("error", "sylius_demo.account.prevent_delete");
         $event->stopPropagation();
     }
 }
开发者ID:Zales0123,项目名称:SyliusDemo,代码行数:13,代码来源:AdminDeleteListener.php

示例4: deleteUser

 /**
  * @param GenericEvent $event
  *
  * @throws \InvalidArgumentException
  */
 public function deleteUser(GenericEvent $event)
 {
     $user = $event->getSubject();
     Assert::isInstanceOf($user, UserInterface::class);
     $token = $this->tokenStorage->getToken();
     if (null !== $token && ($loggedUser = $token->getUser()) && $loggedUser->getId() === $user->getId()) {
         $event->stopPropagation();
         $this->session->getBag('flashes')->add('error', 'Cannot remove currently logged in user.');
     }
 }
开发者ID:loic425,项目名称:Sylius,代码行数:15,代码来源:UserDeleteListener.php

示例5: deleteUser

 /**
  * @param GenericEvent $event
  */
 public function deleteUser(GenericEvent $event)
 {
     $user = $event->getSubject();
     if (!$user instanceof UserInterface) {
         throw new UnexpectedTypeException($user, UserInterface::class);
     }
     if (($token = $this->tokenStorage->getToken()) && ($loggedUser = $token->getUser()) && $loggedUser->getId() === $user->getId()) {
         $event->stopPropagation();
         $this->session->getBag('flashes')->add('error', 'Cannot remove currently logged in user.');
     }
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:14,代码来源:UserDeleteListener.php

示例6:

 function it_does_not_allow_to_delete_currently_logged_user(GenericEvent $event, UserInterface $userToBeDeleted, UserInterface $currentlyLoggedInUser, $tokenStorage, $flashBag, TokenInterface $token)
 {
     $event->getSubject()->willReturn($userToBeDeleted);
     $userToBeDeleted->getId()->willReturn(1);
     $tokenStorage->getToken()->willReturn($token);
     $currentlyLoggedInUser->getId()->willReturn(1);
     $token->getUser()->willReturn($currentlyLoggedInUser);
     $event->stopPropagation()->shouldBeCalled();
     $flashBag->add('error', 'Cannot remove currently logged in user.')->shouldBeCalled();
     $this->deleteUser($event);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:11,代码来源:UserDeleteListenerSpec.php

示例7: onBeforeDelete

 public function onBeforeDelete(Event $event)
 {
     if ($this->isDeletable === false) {
         /** @var \Dja\Db\Model\Model $model */
         $model = $event->getSubject();
         echo 'write is_deleted';
         $model->is_deleted = true;
         $model->save();
         $event->stopPropagation();
         return false;
     }
 }
开发者ID:buldezir,项目名称:dja_orm,代码行数:12,代码来源:HistroryWriteSubscriber.php


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