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


PHP GenericEvent::getSubject方法代码示例

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


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

示例1: onSave

 public function onSave(GenericEvent $event)
 {
     if (get_class($event->getSubject()) == $this->workflowClass) {
         //if it is a 'save' of the workflow entity check the workflow-status of the belonging types and save the formNodes to the real nodes
         $workflow = $event->getSubject();
         //get the repository for the changed workflow
         $repositories = $this->getEntityRepository($workflow);
         if ($repositories != null) {
             //get all ressources without workflow-status
             $resources = array();
             foreach ($repositories as $repository) {
                 $currentResourcesEmpty = $repository->getEmptyWorkflowStatus();
                 //replace old workflowstatus with current workflowstatus
                 $this->removeOldWorkflowStatus($repository, $workflow);
                 $resources = array_merge($currentResourcesEmpty, $resources);
             }
             //check if there are some entries with workflow-status null
             if ($resources != null) {
                 //set a workflow-status if the current workflow is active
                 if ($workflow->getActive()) {
                     $this->setWorkflowStatus($workflow, $resources);
                 }
             }
         }
         $this->writeNodes($workflow, $repositories);
         $this->em->flush();
     }
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:28,代码来源:WorkflowSaveListener.php

示例2: onDelete

 public function onDelete(GenericEvent $event)
 {
     $metadata = $this->metadataFactory->create($event->getSubject());
     //check if the current subject was indexed
     if ($metadata) {
         //get the right IndexEngine
         $engine = $this->container->getParameter('enhavo_search.search.index_engine');
         $indexEngine = $this->container->get($engine);
         //do the unindexing
         $indexEngine->unindex($event->getSubject());
     }
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:12,代码来源:DeleteListener.php

示例3: onDelete

 public function onDelete(GenericEvent $event)
 {
     if (get_class($event->getSubject()) == $this->workflowClass) {
         //get the current workflow
         $workflowRepository = $this->em->getRepository('EnhavoWorkflowBundle:Workflow');
         $workflow = $workflowRepository->find($event->getSubject()->getId());
         //remove transitions from current workflow
         $this->removeTransitions($workflow);
         //remove nodes and workflowstatus from current workflow
         $this->removeNodesAndWorkflowStatus($workflow);
         $this->em->flush();
     }
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:13,代码来源:DeleteListener.php

示例4: checkChannels

 /**
  * Check if channels are linked to this tree
  *
  * @param GenericEvent $event
  *
  * @throws ConflictHttpException
  */
 public function checkChannels(GenericEvent $event)
 {
     $tree = $event->getSubject();
     if (count($tree->getChannels()) > 0) {
         throw new ConflictHttpException($this->translator->trans('flash.tree.not removable'));
     }
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:14,代码来源:CheckChannelsOnDeletionSubscriber.php

示例5: onUpdate

 public function onUpdate(GenericEvent $event)
 {
     $entity = $event->getSubject();
     if ($entity instanceof Routeable && $entity->getRoute() != null) {
         $this->updateRoute($entity->getRoute());
     }
 }
开发者ID:npakai,项目名称:enhavo,代码行数:7,代码来源:DoctrineRouteableSubscriber.php

示例6:

 function it_resolves_order_states(StateResolverInterface $stateResolver, GenericEvent $event, OrderInterface $order)
 {
     $event->getSubject()->willReturn($order);
     $stateResolver->resolveShippingState($order)->shouldBeCalled();
     $stateResolver->resolvePaymentState($order)->shouldBeCalled();
     $this->resolveOrderStates($event);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:7,代码来源:OrderStateListenerSpec.php

示例7:

 function it_send_password_reset_pin_mail($sender, GenericEvent $event, UserInterface $user)
 {
     $event->getSubject()->willReturn($user);
     $user->getEmail()->willReturn('test@example.com');
     $sender->send('reset_password_pin', ['test@example.com'], Argument::any())->shouldBeCalled();
     $this->sendResetPasswordPinEmail($event);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:7,代码来源:MailerListenerSpec.php

示例8:

 function it_proccess_order_channel_successfully(GenericEvent $event, OrderInterface $order, ChannelContextInterface $channelContext, ChannelInterface $channel)
 {
     $event->getSubject()->shouldBeCalled()->willReturn($order);
     $channelContext->getChannel()->shouldBeCalled()->willReturn($channel);
     $order->setChannel($channel)->shouldBeCalled();
     $this->processOrderChannel($event);
 }
开发者ID:Silwereth,项目名称:Sylius,代码行数:7,代码来源:OrderChannelListenerSpec.php

示例9:

 function it_sets_customer_on_a_resource($customerContext, GenericEvent $event, CustomerAwareInterface $resource, CustomerInterface $customer)
 {
     $event->getSubject()->willReturn($resource);
     $customerContext->getCustomer()->willReturn($customer);
     $resource->setCustomer($customer)->shouldBeCalled();
     $this->setCustomer($event);
 }
开发者ID:Silwereth,项目名称:Sylius,代码行数:7,代码来源:CustomerAwareListenerSpec.php

示例10: updateChannel

 /**
  * @param GenericEvent $event
  */
 public function updateChannel(GenericEvent $event)
 {
     $channel = $event->getSubject();
     if (!$channel instanceof ChannelInterface) {
         return;
     }
     $oldLocales = $this->repository->getDeletedLocalesForChannel($channel);
     $newLocales = $channel->getLocales();
     $updatedLocales = [];
     foreach ($oldLocales as $locale) {
         $locale->removeChannel($channel);
         $updatedLocales[] = $locale;
         if (null !== $this->completeness) {
             $this->completeness->scheduleForChannelAndLocale($channel, $locale);
         }
     }
     foreach ($newLocales as $locale) {
         if (!$locale->hasChannel($channel)) {
             $locale->addChannel($channel);
             $updatedLocales[] = $locale;
         }
     }
     if (!empty($updatedLocales)) {
         $this->saver->saveAll($updatedLocales);
     }
 }
开发者ID:aml-bendall,项目名称:ExpandAkeneoApi,代码行数:29,代码来源:ChannelLocaleSubscriber.php

示例11: onCheckoutComplete

 /**
  * {@inheritdoc}
  */
 public function onCheckoutComplete(GenericEvent $event)
 {
     /** @var OrderInterface $order */
     $order = $event->getSubject();
     Assert::isInstanceOf($order, OrderInterface::class);
     $this->session->set('sylius_order_id', $order->getId());
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:CheckoutCompleteListener.php

示例12: login

 public function login(GenericEvent $event)
 {
     $user = $event->getSubject();
     if ($user instanceof UserInterface) {
         $this->userCartMerger->merge($user);
     }
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:7,代码来源:UserSubscriber.php

示例13: onContent

 public function onContent(Event $event)
 {
     $page = $event->getSubject();
     foreach ($page->getDocument()->getElementsByTagName('img') as $image) {
         $url = parse_url($image->getAttribute('src'));
         if (isset($url['host'])) {
             continue;
         }
         if (isset($url['query'])) {
             parse_str($url['query'], $query);
         }
         $src = $this->urlGenerator->generate('image', ['path' => $url['path']]);
         if ('a' !== $image->parentNode->nodeName && (!isset($query['link']) || 'no' !== $query['link'])) {
             $a = $image->parentNode->insertBefore($page->getDocument()->createElement('a'), $image);
             $a->appendChild($image);
             $a->setAttribute('href', $src . (isset($query['link']) && 'direct' === $query['link'] ? '' : '?details'));
         }
         if (isset($query['link'])) {
             unset($query['link']);
         }
         if (!empty($query)) {
             $src .= '?' . http_build_query($query);
         }
         $image->setAttribute('src', $src);
         unset($query);
     }
 }
开发者ID:gitiki,项目名称:gitiki,代码行数:27,代码来源:Image.php

示例14:

 function it_does_not_update_password_if_customer_does_not_have_user(PasswordUpdaterInterface $passwordUpdater, GenericEvent $event, CustomerInterface $customer)
 {
     $event->getSubject()->willReturn($customer);
     $customer->getUser()->willReturn(null);
     $passwordUpdater->updatePassword(null)->shouldNotBeCalled();
     $this->customerUpdateEvent($event);
 }
开发者ID:TeamNovatek,项目名称:Sylius,代码行数:7,代码来源:PasswordUpdaterListenerSpec.php

示例15:

 function it_does_not_set_locale_on_post_update_when_event_subject_is_different_from_current_user($translator, GenericEvent $event, UserInterface $user, RequestStack $requestStack, Request $request, LocaleInterface $locale)
 {
     $event->getSubject()->willReturn($user);
     $event->getArgument('current_user')->willReturn(null);
     $translator->setLocale('fr_FR')->shouldNotBeCalled();
     $this->onPostUpdate($event);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:LocaleSubscriberSpec.php


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