當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。