当前位置: 首页>>代码示例>>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;未经允许,请勿转载。