• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Event\LifecycleEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Doctrine\Common\Persistence\Event\LifecycleEventArgs的典型用法代码示例。如果您正苦于以下问题:PHP LifecycleEventArgs类的具体用法?PHP LifecycleEventArgs怎么用?PHP LifecycleEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: preUpdate

 public function preUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof User) {
         $this->updatePassword($entity);
     }
 }
开发者ID:drymek,项目名称:fcs-backend,代码行数:7,代码来源:PasswordListener.php


示例2: 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


示例3: prePersist

 public function prePersist(LifecycleEventArgs $args)
 {
     $object = $args->getObject();
     if ($object instanceof FileInterface) {
         $object->upload();
     }
 }
开发者ID:profcab,项目名称:ilios,代码行数:7,代码来源:LearningMaterialListener.php


示例4: 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


示例5: updateRoute

 protected function updateRoute(LifecycleEventArgs $args)
 {
     $object = $args->getObject();
     if ($object instanceof MenuInterface) {
         $object->setRouter($this->router);
     }
 }
开发者ID:foreverglory,项目名称:menu-bundle,代码行数:7,代码来源:RouteListener.php


示例6: 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


示例7: 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


示例8:

 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


示例9: preUpdate

 public function preUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     if (method_exists($entity, 'setUpdateDate')) {
         $entity->setUpdateDate(new \DateTime());
     }
 }
开发者ID:hiroyasu55,项目名称:ec-cube,代码行数:7,代码来源:SaveEventSubscriber.php


示例10: preRemove

 /**
  * Removes image file
  * @param  LifecycleEventArgs $event
  */
 public function preRemove(LifecycleEventArgs $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof ImageInterface) {
         $this->uploader->remove($entity);
     }
 }
开发者ID:fullpipe,项目名称:image-bundle,代码行数:11,代码来源:ImageUploadListener.php


示例11: preUpdate

 /**
  * @param LifecycleEventArgs $eventArgs
  */
 public function preUpdate(LifecycleEventArgs $eventArgs)
 {
     $object = $eventArgs->getObject();
     if ($this->isSluggable($object)) {
         $this->updateSlug($object);
     }
 }
开发者ID:kumfo,项目名称:Sylius,代码行数:10,代码来源:ProductTranslationSlugEventListener.php


示例12: 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


示例13: 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


示例14:

 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


示例15: fixOrders

 private function fixOrders(LifecycleEventArgs $event)
 {
     $entity = $event->getEntity();
     if (!$entity instanceof \UR\DB\NewBundle\Entity\BasePerson) {
         return;
     }
     $personId = $entity->getId();
     $this->LOGGER->debug("Fixing orders for ID: " . $personId);
     $em = $event->getEntityManager();
     $education = $em->getRepository('NewBundle:Education')->findBy(array('person' => $personId), array('educationOrder' => 'ASC'));
     $this->fixArray($em, $education, PersonInformation::EDUCATION);
     $honour = $em->getRepository('NewBundle:Honour')->findBy(array('person' => $personId), array('honourOrder' => 'ASC'));
     $this->fixArray($em, $honour, PersonInformation::HONOUR);
     $property = $em->getRepository('NewBundle:Property')->findBy(array('person' => $personId), array('propertyOrder' => 'ASC'));
     $this->fixArray($em, $property, PersonInformation::PROPERTY);
     $rank = $em->getRepository('NewBundle:Rank')->findBy(array('person' => $personId), array('rankOrder' => 'ASC'));
     $this->fixArray($em, $rank, PersonInformation::RANK);
     $religion = $em->getRepository('NewBundle:Religion')->findBy(array('person' => $personId), array('religionOrder' => 'ASC'));
     $this->fixArray($em, $religion, PersonInformation::RELIGION);
     $roadOfLife = $em->getRepository('NewBundle:RoadOfLife')->findBy(array('person' => $personId), array('roadOfLifeOrder' => 'ASC'));
     $this->fixArray($em, $roadOfLife, PersonInformation::ROAD_OF_LIFE);
     $status = $em->getRepository('NewBundle:Status')->findBy(array('person' => $personId), array('statusOrder' => 'ASC'));
     $this->fixArray($em, $status, PersonInformation::STATUS);
     $works = $em->getRepository('NewBundle:Works')->findBy(array('person' => $personId), array('worksOrder' => 'ASC'));
     $this->fixArray($em, $works, PersonInformation::WORK);
     if ($entity instanceof \UR\DB\NewBundle\Entity\Person) {
         $source = $em->getRepository('NewBundle:Source')->findBy(array('person' => $personId), array('sourceOrder' => 'ASC'));
         $this->fixArray($em, $source, PersonInformation::SOURCE);
     }
     $em->flush();
 }
开发者ID:JhnMhf,项目名称:SimpleProject,代码行数:31,代码来源:FixDBOrdersEventSubscriber.php


示例16: let

 function let(Generator $generator, HasInitialPassword $user, LifecycleEventArgs $event)
 {
     $generator->generate()->willReturn('password');
     $event->getObject()->willReturn($user);
     $user->getPlainPassword()->willReturn(null);
     $this->beConstructedWith($generator);
 }
开发者ID:knplabs,项目名称:rad-user,代码行数:7,代码来源:PasswordGenerationListenerSpec.php


示例17: preRemove

 public function preRemove(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if ($this->isReferenceable($object)) {
         $this->objectAdapterManager->removeReference($object);
     }
 }
开发者ID:joschi127,项目名称:DoctrineOrmOdmAdapter,代码行数:7,代码来源:PhpcrLifecycleListener.php


示例18: onPaymentBeforeSave

 public function onPaymentBeforeSave(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     if ($entity instanceof PaymentInterface) {
         $this->getPaymentStateHistoryManager()->createPaymentStateHistory($entity);
     }
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:7,代码来源:PaymentDoctrineEventSubscriber.php


示例19: postUpdate

 /**
  * Cette methode sera appelé depuis mon services.yml
  * ET reçoie en argument mon evenement Doctrine 2
  * @param LifecycleEventArgs $args
  */
 public function postUpdate(LifecycleEventArgs $args)
 {
     // Je récupère mon objet après modification (update)
     $entity = $args->getEntity();
     $em = $args->getEntityManager();
     // récupérer l'Entité Manager
     // Si mon objet est un objet de mon entité Product
     if ($entity instanceof Product) {
         // récupéré le titre de mion produit
         $title = $entity->getTitle();
         # 2 tableaux avec accents
         $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'Ð', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', 'Œ', 'œ', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'Š', 'š', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Ÿ', 'Z', 'z', 'Z', 'z', 'Ž', 'ž', '?', 'ƒ', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?');
         $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
         // slugifier mon titre stocké dans une variable slug
         $slug = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $title)));
         // setSlug me permet de modifier le slug de mon product
         $entity->setSlug($slug);
         $em->persist($entity);
         //j'enregistre en base de données
         $em->flush();
         // quand la quantité sera égal à 1
         if ($entity->getQuantity() == 1) {
             $this->notification->notify($entity->getId(), 'Attention, votre produit ' . $entity->getTitle() . '  a une seule quantité', 'product', 'danger');
         } else {
             if ($entity->getQuantity() < 5) {
                 // je notifie la quantité de ce produit
                 // avec la methode notify()
                 $this->notification->notify($entity->getId(), 'Attention, votre produit ' . $entity->getTitle() . '  a un stocke bientôt épuisé', 'product', 'warning');
             }
         }
     }
 }
开发者ID:unpetitlu,项目名称:store,代码行数:37,代码来源:ProductListener.php


示例20: 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



注:本文中的Doctrine\Common\Persistence\Event\LifecycleEventArgs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Mapping\ClassMetadata类代码示例发布时间:2022-05-23
下一篇:
PHP Persistence\ObjectRepository类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap