php Symfony-Component-EventDispatcher-GenericEvent类(方法)实例源码

下面列出了php Symfony-Component-EventDispatcher-GenericEvent 类(方法)源码代码实例,从而了解它的用法。

作者:npaka    项目:enhav   
public function onUpdate(GenericEvent $event)
 {
     $entity = $event->getSubject();
     if ($entity instanceof Routeable && $entity->getRoute() != null) {
         $this->updateRoute($entity->getRoute());
     }
 }

作者:gabiudresc    项目:Syliu   
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);
 }

作者:ReissClothin    项目:Syliu   
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);
 }

作者:okwinz    项目:Syliu   
function it_does_not_proceed_order_channel_if_it_is_already_set(GenericEvent $event, OrderInterface $order, ChannelInterface $channel)
 {
     $event->getSubject()->willReturn($order);
     $order->getChannel()->willReturn($channel);
     $order->setChannel($channel)->shouldNotBeCalled();
     $this->processOrderChannel($event);
 }

作者:Silweret    项目:Syliu   
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);
 }

作者:ReissClothin    项目:Syliu   
/**
  * {@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());
 }

作者:aml-bendal    项目:ExpandAkeneoAp   
/**
  * @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);
     }
 }

作者:enhav    项目:enhav   
public function login(GenericEvent $event)
 {
     $user = $event->getSubject();
     if ($user instanceof UserInterface) {
         $this->userCartMerger->merge($user);
     }
 }

作者:mazela    项目:phantomjsstarte   
/**
  * Starts a new phantomjs process in background
  *
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  */
 public function up()
 {
     $this->killAllRunning();
     $this->process = new Process('phantomjs --webdriver=' . $this->port . ' ' . $this->options);
     $process = $this->process;
     $output = new GenericEvent();
     $process->setTimeout(null);
     $process->start(function () use($process, $output) {
         $output->setArgument('output', $process->getIncrementalOutput());
     });
     $phantomjsOnline = false;
     $portScan = false;
     while (!$phantomjsOnline) {
         if ($output->hasArgument('output')) {
             $portScan = strpos($output->getArgument('output'), 'running on port ' . $this->port);
         }
         if ($portScan) {
             echo $output->getArgument('output');
         }
         $phantomjsOnline = $process->isStarted() && $process->isRunning() && $portScan;
         if ($process->isTerminated()) {
             throw new RuntimeException('Phantomjs could not been started with webdriver on port ' . $this->port);
         }
     }
 }

作者:TeamNovate    项目:Syliu   
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);
 }

作者:a2xchi    项目:pim-community-de   
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);
 }

作者:javiersanto    项目:pim-community-de   
/**
  * 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'));
     }
 }

作者:phppr    项目:sd   
/**
  * @param GenericEvent $event
  */
 public function onApiCall(GenericEvent $event)
 {
     if (!$this->calls) {
         $this->calls = [];
     }
     $this->calls[] = $event->getSubject();
 }

作者:worldi    项目:textmaster-bundl   
/**
  * Mark document's related job as 'started'.
  *
  * @param GenericEvent $event
  */
 public function onTextmasterDocumentIncomplete(GenericEvent $event)
 {
     /** @var DocumentInterface $document */
     $document = $event->getSubject();
     $job = $this->jobManager->getFromDocument($document);
     $this->jobManager->start($job);
 }

作者:artgg    项目:EasyAdminBundl   
public function initializeRequest(GenericEvent $event)
 {
     if (null === $this->request) {
         return;
     }
     $this->request->attributes->set('easyadmin', array('entity' => $entity = $event->getArgument('entity'), 'view' => $this->request->query->get('action', 'list'), 'item' => ($id = $this->request->query->get('id')) ? $this->findCurrentItem($entity, $id) : null));
 }

作者:Silweret    项目:Syliu   
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);
 }

作者:enhav    项目:enhav   
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();
     }
 }

作者:sourcefabri    项目:newscoo   
/**
  * 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));
 }

作者:TheMadelein    项目:Syliu   
function it_does_nothing_if_review_already_has_author($customerContext, ReviewerInterface $existingAuthor, GenericEvent $event, ReviewInterface $review)
 {
     $event->getSubject()->willReturn($review);
     $review->getAuthor()->willReturn($existingAuthor);
     $customerContext->getCustomer()->shouldNotBeCalled();
     $this->ensureReviewHasAuthor($event);
 }

作者:alehers    项目:Syliu   
function it_calls_taxation_processor_on_order(TaxationProcessorInterface $taxationProcessor, GenericEvent $event, OrderInterface $order)
 {
     $event->getSubject()->willReturn($order);
     $taxationProcessor->applyTaxes($order)->shouldBeCalled();
     $order->calculateTotal()->shouldBeCalled();
     $this->applyTaxes($event);
 }


问题


面经


文章

微信
公众号

扫码关注公众号