當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LifecycleEventArgs::getObject方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Persistence\Event\LifecycleEventArgs::getObject方法的典型用法代碼示例。如果您正苦於以下問題:PHP LifecycleEventArgs::getObject方法的具體用法?PHP LifecycleEventArgs::getObject怎麽用?PHP LifecycleEventArgs::getObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Persistence\Event\LifecycleEventArgs的用法示例。


在下文中一共展示了LifecycleEventArgs::getObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: preUpdate

 /**
  * @param \Doctrine\Common\Persistence\Event\LifecycleEventArgs $event
  */
 public function preUpdate(LifecycleEventArgs $event)
 {
     if (!$this->supports($event->getObject())) {
         return;
     }
     $object = $event->getObject();
     $object->setUpdatedAt($this->now());
     $dm = $event->getDocumentManager();
     $class = $dm->getClassMetadata(get_class($object));
     $dm->getUnitOfWork()->recomputeSingleDocumentChangeSet($class, $object);
 }
開發者ID:staffim,項目名稱:StaffimTimestampableBundle,代碼行數:14,代碼來源:TimestampableSubscriber.php

示例2: preRemove

 public function preRemove(LifecycleEventArgs $args)
 {
     if (!$args->getObject() instanceof Payment) {
         return;
     }
     $entity = $args->getObject();
     $entityManager = $args->getObjectManager();
     $products = $entityManager->getRepository("CvaGestionMembreBundle:Produit")->findBy(['hasWaitingList' => true]);
     if ($entity instanceof Payment) {
         if (in_array($entity->getProduct(), $products)) {
             $this->containerInterface->get("bde.wei.registration_management")->removeFromWaitingList($entity->getStudent(), $entity->getProduct());
         }
     }
 }
開發者ID:PhilippeGeek,項目名稱:adhesion,代碼行數:14,代碼來源:PaymentListener.php

示例3: PostUpdate

 public function PostUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     $em = $args->getObjectManager();
     $classMetaData = $em->getClassMetadata(get_class($entity));
     foreach ($classMetaData->associationMappings as $associationMappingKey => $associationMappingDatas) {
         if ($associationMappingDatas['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::ONE_TO_MANY) {
             $repo = $em->getRepository($associationMappingDatas['targetEntity']);
             $associated = $repo->findBy([$associationMappingDatas['mappedBy'] => $entity]);
             $newAssociated = call_user_func([$entity, 'get' . ucfirst($associationMappingKey)]);
             $changed = false;
             foreach ($associated as $associatedEntity) {
                 if (!$newAssociated->contains($associatedEntity)) {
                     $changed = true;
                     $em->remove($associatedEntity);
                 }
             }
             if ($changed) {
                 $em->flush();
             }
             //
         }
     }
     //        dump($classMetaData);
     //        die();
 }
開發者ID:kokmok,項目名稱:SKCMS-Admin,代碼行數:26,代碼來源:OneToManyDeleteListener.php

示例4: onPaymentBeforeSave

 public function onPaymentBeforeSave(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     if ($entity instanceof PaymentInterface) {
         $this->getPaymentStateHistoryManager()->createPaymentStateHistory($entity);
     }
 }
開發者ID:wellcommerce,項目名稱:wellcommerce,代碼行數:7,代碼來源:PaymentDoctrineEventSubscriber.php

示例5: preUpdate

 /**
  * Pre update
  * PreUpdate event needs to recompute change set
  *
  * @param LifecycleEventArgs $args
  */
 public function preUpdate(LifecycleEventArgs $args)
 {
     $object = $args->getObject();
     if ($object instanceof AbstractMetric && $object->getUnit()) {
         $this->createMetricBaseValues($object);
     }
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:13,代碼來源:MetricBaseValuesSubscriber.php

示例6: updateRoute

 protected function updateRoute(LifecycleEventArgs $args)
 {
     $object = $args->getObject();
     if ($object instanceof MenuInterface) {
         $object->setRouter($this->router);
     }
 }
開發者ID:foreverglory,項目名稱:menu-bundle,代碼行數:7,代碼來源:RouteListener.php

示例7: postRemove

 public function postRemove(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     $reflection = new \ReflectionClass($object);
     $message = sprintf('%s deleted', $reflection->getShortName());
     $this->logger->notice($message, $this->getContext($object));
 }
開發者ID:dstansby,項目名稱:camdram,代碼行數:7,代碼來源:DoctrineEventLogger.php

示例8: postPersist

 /**
  * @param EventArgs|LifecycleEventArgs $args
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     $em = $args->getObjectManager();
     if ($entity instanceof Comment) {
         if ($entity->getArticleId() != null) {
             if ($entity->getUserId()->getId() != $entity->getArticleId()->getUserId()->getId()) {
                 $n = new Notification();
                 $n->setUser($entity->getUserId())->setArticle($entity->getArticleId());
                 $em->persist($n);
                 $em->flush();
             }
         } else {
             if ($entity->getVideoId() != null) {
                 if ($entity->getUserId()->getId() != $entity->getVideoId()->getUserId()->getId()) {
                     $n = new Notification();
                     $n->setUser($entity->getUserId())->setVideo($entity->getVideoId());
                     $em->persist($n);
                     $em->flush();
                 }
             } else {
                 if ($entity->getLinkId() != null) {
                     if ($entity->getUserId()->getId() != $entity->getLinkId()->getUserId()->getId()) {
                         $n = new Notification();
                         $n->setUser($entity->getUserId())->setLink($entity->getLinkId());
                         $em->persist($n);
                         $em->flush();
                     }
                 }
             }
         }
     }
 }
開發者ID:ugra92,項目名稱:knowledgems,代碼行數:36,代碼來源:NotificationListener.php

示例9: let

 function let(Generator $generator, HasSalt $user, LifecycleEventArgs $event)
 {
     $generator->generate()->willReturn('salt');
     $event->getObject()->willReturn($user);
     $user->getSalt()->willReturn(null);
     $this->beConstructedWith($generator);
 }
開發者ID:knplabs,項目名稱:rad-user,代碼行數:7,代碼來源:SaltGenerationListenerSpec.php

示例10:

 function it_marks_indexed_product_values_outdated_after_loading_a_value(LifecycleEventArgs $args, ProductValueInterface $value, ProductInterface $entity)
 {
     $args->getObject()->willReturn($value);
     $value->getEntity()->willReturn($entity);
     $entity->markIndexedValuesOutdated()->shouldBeCalled();
     $this->postLoad($args);
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:7,代碼來源:OutdateIndexedValuesSubscriberSpec.php

示例11: postUpdate

 /**
  * Control object dms
  *
  * @param LifecycleEventArgs $args
  */
 public function postUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     if ($entity instanceof GedableInterface) {
         $this->manageNodeTree($entity->getGedTree());
     }
 }
開發者ID:DavidG04,項目名稱:ErichardDmsBundle,代碼行數:12,代碼來源:GedableListener.php

示例12: preUpdate

 /**
  * Pre update listener based on doctrine commons, overwrite to update
  * the changeset in the UoW and to handle non-common event argument
  * class.
  *
  * @param LifecycleEventArgs $args weak typed to allow overwriting
  */
 public function preUpdate($args)
 {
     $object = $args->getObject();
     if ($object instanceof UserInterface) {
         $this->updateUserFields($object);
     }
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:14,代碼來源:AbstractUserListener.php

示例13: preRemove

 public function preRemove(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if ($this->isReferenceable($object)) {
         $this->objectAdapterManager->removeReference($object);
     }
 }
開發者ID:joschi127,項目名稱:DoctrineOrmOdmAdapter,代碼行數:7,代碼來源:PhpcrLifecycleListener.php

示例14:

 function it_applies_during_pre_update_on_timestampable_object(LifecycleEventArgs $args, TimestampableInterface $object)
 {
     $args->getObject()->willReturn($object);
     $object->setCreated()->shouldNotBeCalled();
     $object->setUpdated(Argument::type('\\DateTime'))->shouldBeCalled();
     $this->preUpdate($args);
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:7,代碼來源:TimestampableSubscriberSpec.php

示例15: prePersist

 public function prePersist(LifecycleEventArgs $args)
 {
     $object = $args->getObject();
     if ($object instanceof FileInterface) {
         $object->upload();
     }
 }
開發者ID:profcab,項目名稱:ilios,代碼行數:7,代碼來源:LearningMaterialListener.php


注:本文中的Doctrine\Common\Persistence\Event\LifecycleEventArgs::getObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。