本文整理汇总了PHP中Symfony\Component\EventDispatcher\GenericEvent::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP GenericEvent::getName方法的具体用法?PHP GenericEvent::getName怎么用?PHP GenericEvent::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\GenericEvent
的用法示例。
在下文中一共展示了GenericEvent::getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleCouponPromotion
/**
* Handle coupons added by the user in his cart.
* TODO: maybe replace this with a unified FlashSubscriber.
*
* @param GenericEvent $event
*/
public function handleCouponPromotion(GenericEvent $event)
{
if (SyliusPromotionEvents::COUPON_ELIGIBLE === $event->getName()) {
$type = 'success';
$message = 'sylius.promotion_coupon.eligible';
} elseif (SyliusPromotionEvents::COUPON_NOT_ELIGIBLE === $event->getName()) {
$type = 'error';
$message = 'sylius.promotion_coupon.not_eligible';
} else {
$type = 'error';
$message = 'sylius.promotion_coupon.invalid';
}
$this->session->getBag('flashes')->add($type, $this->translator->trans($message, array(), 'flashes'));
}
示例2: update
/**
* Update community ticker
*
* @param GenericEvent $event
* @return void
*/
public function update(GenericEvent $event)
{
$params = $event->getArguments();
$user = array_key_exists('user', $params) ? $params['user'] : null;
unset($params['user']);
$this->getRepository()->save(new CommunityTickerEvent(), array('event' => $event->getName(), 'user' => $user, 'params' => $params));
}
示例3:
function it_adds_error_message_to_flashbag_when_coupon_is_not_eligible(GenericEvent $event, FlashBagInterface $flashBag, $session, $translator)
{
$event->getName()->willReturn(SyliusPromotionEvents::COUPON_NOT_ELIGIBLE);
$translator->trans(Argument::any(), Argument::any(), 'flashes')->shouldBeCalled();
$flashBag->add('error', Argument::any())->shouldBeCalled();
$session->getBag('flashes')->shouldBeCalled()->willReturn($flashBag);
$this->handleCouponPromotion($event);
}