本文整理匯總了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);
}