本文整理汇总了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);
}
示例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()));
}
}
示例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();
}
}
示例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.');
}
}
示例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.');
}
}
示例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);
}
示例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;
}
}