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


PHP LifecycleEventArgs::getEntity方法代码示例

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


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

示例1: postRemove

 /**
  *
  * @param LifecycleEventArgs $args
  * @param FileUpload $annotation
  */
 public function postRemove(LifecycleEventArgs $args, FileUpload $annotation)
 {
     $entity = $args->getEntity();
     $entity = $args->getEntity();
     $annotation = $this->getFileUploadAnnotation();
     if (!$annotation) {
         return;
     }
     $file = sprintf('%s/%s%s', $this->uploadRootDir, $annotation->getUploadSubDirectory(), $entity->{$annotation->getFilepath()}());
     if (is_file($file) && is_writable($file)) {
         unlink($file);
     }
 }
开发者ID:zebba,项目名称:AnnotationBundle,代码行数:18,代码来源:FileUploadHandler.php

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

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

示例4: preUpdate

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

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

示例6: preUpdate

 /**
  * Handels user pre update event.
  *
  * @param LifecycleEventArgs $event A LifecycleEventArgs instacne
  */
 public function preUpdate(LifecycleEventArgs $event)
 {
     $user = $event->getEntity();
     if (!$user instanceof UserInterface) {
         return;
     }
     $this->setPassword($user);
 }
开发者ID:sfblaauw,项目名称:pulsar,代码行数:13,代码来源:UserListener.php

示例7: preRemove

 /**
  * Delete document on objects after being remove
  *
  * @param LifecycleEventArgs $args
  * @return void
  */
 public function preRemove(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($index = $this->getIndexForObject($entity)) {
         $indexManager = new IndexManager($index);
         $indexManager->remove($entity);
     }
 }
开发者ID:diskojulien,项目名称:keratine,代码行数:14,代码来源:IndexableListener.php

示例8: prePersist

 public function prePersist(LifecycleEventArgs $args)
 {
     $item = $args->getEntity();
     if (!$this->supports($item)) {
         return;
     }
     $this->eventDispatcher->dispatch('sylius.order_item.pre_create', new GenericEvent($item));
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:8,代码来源:OrderItemInventoryListener.php

示例9: prePersist

 /**
  * @param LifecycleEventArgs $args
  */
 public function prePersist(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     // only act on some "Product" entity
     if (!$entity instanceof Personne) {
         return;
     }
     $entityManager = $args->getEntityManager();
     // ... do something with the Product
     $logger = $this->get('logger');
     $logger->addDebug('Doctrine event: personne: ' . $entity->getStatus());
 }
开发者ID:m2fd,项目名称:crud-contacts,代码行数:15,代码来源:logEntity.php

示例10: preRemove

 /**
  * Delete document on objects after being remove
  *
  * @param LifecycleEventArgs $args
  * @return void
  */
 public function preRemove(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $entityManager = $args->getObjectManager();
     $meta = $entityManager->getClassMetadata(get_class($entity));
     foreach ($meta->fieldMappings as $field => $options) {
         $reflProperty = new ReflectionProperty($meta->getName(), $field);
         $annotation = $this->getAnnotationReader()->getPropertyAnnotation($reflProperty, '\\Keratine\\Doctrine\\Mapping\\Annotation\\Thumbnail');
         if ($annotation) {
             $accessor = PropertyAccess::createPropertyAccessor();
             $sourcePath = $accessor->getValue($entity, $annotation->path);
             if (!$sourcePath) {
                 return;
             }
             foreach ($annotation->sizes as $name => $size) {
                 $destinationPath = dirname($sourcePath) . '/' . $name . '/' . basename($sourcePath);
                 if (file_exists($destinationPath)) {
                     unlink($destinationPath);
                 }
             }
         }
     }
 }
开发者ID:diskojulien,项目名称:keratine,代码行数:29,代码来源:ThumbnailListener.php

示例11: switchToId

 protected function switchToId(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $entity->status = $entity->status->value;
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:5,代码来源:EventObjectUpdateTest.php

示例12: getFileUploadAnnotation

 /**
  *
  * @param object $entity
  * @return FileUpload|NULL
  */
 private function getFileUploadAnnotation(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $reflectionClass = $args->getObjectManager()->getClassMetadata(get_class($entity))->getReflectionClass();
     return $this->reader->getClassAnnotation($reflectionClass, self::ANNOTATION);
 }
开发者ID:zebba,项目名称:AnnotationBundle,代码行数:11,代码来源:FileUploadListener.php

示例13: saveDateToDB

 private function saveDateToDB(LifecycleEventArgs $event)
 {
     $entity = $event->getEntity();
     $em = $event->getEntityManager();
     $this->LOGGER->debug("Saving Dates to db for: " . $entity);
     switch (get_class($entity)) {
         case "UR\\DB\\NewBundle\\Entity\\Date":
             return;
         case "UR\\DB\\NewBundle\\Entity\\Partner":
         case "UR\\DB\\NewBundle\\Entity\\Person":
         case "UR\\DB\\NewBundle\\Entity\\Relative":
             $this->LOGGER->debug("Found 'person' entity: " . $entity);
             //@TODO: Is there sth to do here?
             break;
         case "UR\\DB\\NewBundle\\Entity\\Baptism":
             $this->LOGGER->debug("Found baptism entity");
             $this->saveDateReference($em, $entity->getBaptismDate());
             break;
         case "UR\\DB\\NewBundle\\Entity\\Birth":
             $this->LOGGER->debug("Found birth entity");
             $this->saveDateReference($em, $entity->getBirthDate());
             $this->saveDateReference($em, $entity->getProvenDate());
             break;
         case "UR\\DB\\NewBundle\\Entity\\Death":
             $this->LOGGER->debug("Found death entity");
             $this->saveDateReference($em, $entity->getDeathDate());
             $this->saveDateReference($em, $entity->getFuneralDate());
             break;
         case "UR\\DB\\NewBundle\\Entity\\Education":
             $this->LOGGER->debug("Found education entity");
             $this->saveFromToProvenDates($em, $entity);
             $this->saveDateReference($em, $entity->getGraduationDate());
             break;
         case "UR\\DB\\NewBundle\\Entity\\Honour":
             $this->LOGGER->debug("Found honour entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         case "UR\\DB\\NewBundle\\Entity\\Property":
             $this->LOGGER->debug("Found property entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         case "UR\\DB\\NewBundle\\Entity\\Rank":
             $this->LOGGER->debug("Found rank entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         case "UR\\DB\\NewBundle\\Entity\\Religion":
             $this->LOGGER->debug("Found religion entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         case "UR\\DB\\NewBundle\\Entity\\RoadOfLife":
             $this->LOGGER->debug("Found roadOfLife entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         case "UR\\DB\\NewBundle\\Entity\\Status":
             $this->LOGGER->debug("Found status entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         case "UR\\DB\\NewBundle\\Entity\\Wedding":
             $this->LOGGER->debug("Found wedding entity");
             $this->saveDateReference($em, $entity->getWeddingDate());
             $this->saveDateReference($em, $entity->getBannsDate());
             $this->saveDateReference($em, $entity->getBreakupDate());
             $this->saveDateReference($em, $entity->getProvenDate());
             break;
         case "UR\\DB\\NewBundle\\Entity\\Works":
             $this->LOGGER->debug("Found works entity");
             $this->saveFromToProvenDates($em, $entity);
             break;
         default:
             $this->LOGGER->debug("Nothing to do here");
             break;
     }
     $this->LOGGER->debug("Finished saving Dates to db for: " . $entity);
     //NO FLUSH ALLOWED IN PRE UPDATE/ PRE PERSIST!
     //http://stackoverflow.com/questions/30576245/infinite-loop-in-doctrine-event-listener-when-trying-to-save-additional-entity
 }
开发者ID:JhnMhf,项目名称:SimpleProject,代码行数:76,代码来源:DateReferenceSubscriber.php

示例14: trigger

 /**
  * Compose and trigger the event.
  *
  * @param string $eventName
  * @param LifecycleEventArgs $args
  */
 protected function trigger($eventName, LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $identifiers = [get_class($entity)];
     if ($entity instanceof OmekaResource) {
         // Add the identifier for a generic resource entity.
         $identifiers[] = 'Omeka\\Entity\\Resource';
     }
     $this->events->setIdentifiers($identifiers);
     $event = new OmekaEvent($eventName, $entity, ['services' => $this->services]);
     $this->events->trigger($event);
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:18,代码来源:Entity.php


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