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


PHP LifecycleEventArgs::getEntity方法代码示例

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


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

示例1: postLoad

 /**
  * After WorkflowItem loaded, de-serialize WorkflowItem
  *
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($this->isSupported($args->getEntity($entity))) {
         $this->deserialize($entity);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:12,代码来源:WorkflowDataSerializeSubscriber.php

示例2: preSave

 /**
  * Handle pre save event
  *
  * @param LifecycleEventArgs $args Event arguments
  */
 protected function preSave(LifecycleEventArgs $args)
 {
     $annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
     if (0 === count($annotations)) {
         return;
     }
     foreach ($annotations as $field => $annotation) {
         $config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
         if (!(isset($config['use_orphanage']) && $config['use_orphanage'])) {
             continue;
         }
         $value = (array) PropertyAccess::createPropertyAccessor()->getValue($args->getEntity(), $field);
         $value = array_filter($value, 'strlen');
         $value = array_map(function ($file) {
             return pathinfo($file, PATHINFO_BASENAME);
         }, $value);
         if (empty($value)) {
             continue;
         }
         $orphanageStorage = $this->container->get('oneup_uploader.orphanage.' . $annotation->endpoint);
         $files = [];
         foreach ($orphanageStorage->getFiles() as $file) {
             if (in_array($file->getBasename(), $value, true)) {
                 $files[] = $file;
             }
         }
         $orphanageStorage->uploadFiles($files);
     }
 }
开发者ID:snovichkov,项目名称:UploaderBundle,代码行数:34,代码来源:UploadListener.php

示例3: preRemove

 public function preRemove(LifecycleEventArgs $args)
 {
     if ($args->getEntity() instanceof Appearance) {
         $appearance = $args->getEntity();
         $appearance->setPlayer(null);
         $appearance->setGame(null);
     }
 }
开发者ID:loske,项目名称:fsdzadatak,代码行数:8,代码来源:RemoveApearanceListener.php

示例4: postLoad

 public function postLoad(LifecycleEventArgs $event)
 {
     if ($event->getEntity() instanceof Repository) {
         $event->getEntity()->init($this->container);
     }
     if ($event->getEntity() instanceof StoredFile) {
         $event->getEntity()->init($this->container);
     }
 }
开发者ID:modera,项目名称:foundation,代码行数:9,代码来源:ContainerInjectorListener.php

示例5: postLoad

 public function postLoad(LifecycleEventArgs $event)
 {
     if ($event->getEntity() instanceof PartAttachment) {
         /**
          * @var $entity PartAttachment
          */
         $entity = $event->getEntity();
         $entity->setImage($this->imageService->canHandleMimetype($entity->getMimeType()));
     }
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:10,代码来源:ImageAttachmentListener.php

示例6: postRemove

 /**
  * @param LifecycleEventArgs $eventArgs
  * @return void
  */
 public function postRemove(LifecycleEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if ($entity instanceof ImageInterface) {
         /** @var PersistentResource $resource */
         $resource = $eventArgs->getEntity()->getResource();
         if ($resource !== null) {
             $this->cacheManager->getCache('TYPO3_Media_ImageSize')->remove($resource->getCacheEntryIdentifier());
         }
     }
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:15,代码来源:ImageEventListener.php

示例7: flush

 protected function flush(LifecycleEventArgs $args)
 {
     $identifier = $this->collectionIdentifiers->getIdentifier($args->getEntity());
     if ($identifier === false) {
         return;
     }
     $parameters = array(get_class($args->getEntity()) => $identifier);
     foreach ($this->caches as $cache) {
         $cache->flush($parameters);
     }
 }
开发者ID:norfil,项目名称:SonataPageBundle,代码行数:11,代码来源:DoctrineORMListener.php

示例8: preRemove

 /**
  * When element answers are deleted they need to notify thier jazzee elements
  * 
  * @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
  */
 public function preRemove(\Doctrine\ORM\Event\LifecycleEventArgs $eventArgs)
 {
     switch (get_class($eventArgs->getEntity())) {
         case 'Jazzee\\Entity\\Answer':
             $answer = $eventArgs->getEntity();
             foreach ($answer->getElementAnswers() as $elementAnswer) {
                 $elementAnswer->preRemove();
             }
             if ($attachment = $answer->getAttachment()) {
                 $attachment->preRemove();
             }
             break;
     }
 }
开发者ID:Jazzee,项目名称:Jazzee,代码行数:19,代码来源:AnswerEventListener.php

示例9: update

 /**
  * @param LifecycleEventArgs $args
  * @param bool $remove
  */
 protected function update(LifecycleEventArgs $args, $remove)
 {
     $alias = $this->builder->getEntityAlias($args->getEntity());
     $this->keeper->set($alias, new \DateTime());
     if ($this->track_individually_entity) {
         $ids = $this->builder->getEntityIdentifier($args->getEntity());
         if ($ids !== null) {
             if ($remove) {
                 $this->keeper->remove($alias . $ids);
             } else {
                 $this->keeper->set($alias . $ids, new \DateTime());
             }
         }
     }
 }
开发者ID:anime-db,项目名称:cache-time-keeper-bundle,代码行数:19,代码来源:DoctrineListener.php

示例10: prePersist

 public function prePersist(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof Layout) {
         $entity->setEngine($this->engineParameter);
     }
 }
开发者ID:shinmen,项目名称:layoutdesigner,代码行数:7,代码来源:LayoutDataListener.php

示例11: prePersist

 public function prePersist(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof User) {
         $this->handleEvent($entity);
     }
 }
开发者ID:GuinetPro,项目名称:Aplicacion-Eventos-Symfony2,代码行数:7,代码来源:UserListener.php

示例12:

 function it_canonicalize_only_user_or_customer_interface_implementation_on_pre_update($canonicalizer, LifecycleEventArgs $event)
 {
     $item = new \stdClass();
     $event->getEntity()->willReturn($item);
     $canonicalizer->canonicalize(Argument::any())->shouldNotBeCalled();
     $this->preUpdate($event);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:7,代码来源:CanonicalizerListenerSpec.php

示例13:

 function it_updates_password_on_pre_update_doctrine_event_for_user_interface_implementation_only($passwordUpdater, LifecycleEventArgs $event, UserInterface $user)
 {
     $user = '';
     $event->getEntity()->willReturn($user);
     $passwordUpdater->updatePassword($user)->shouldNotBeCalled();
     $this->preUpdate($event);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:7,代码来源:PasswordUpdaterListenerSpec.php

示例14: postLoad

 /**
  * @param LifecycleEventArgs $event
  */
 public function postLoad(LifecycleEventArgs $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof ConfigurationEntry) {
         $entity->init($this->container);
     }
 }
开发者ID:modera,项目名称:foundation,代码行数:10,代码来源:InitConfigurationEntry.php

示例15: postLoad

 public function postLoad(LifecycleEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entity = $eventArgs->getEntity();
     $classname = get_class($entity);
     if (!array_key_exists($classname, $this->getEntities())) {
         return null;
     }
     /** @var Schema $schema */
     $schema = $em->getRepository('Padam87AttributeBundle:Schema')->findOneBy(array('className' => $classname));
     if ($schema === null) {
         throw new \UnexpectedValueException('Schema not found for ' . $classname);
     }
     $qb = $em->getRepository($classname)->createQueryBuilder('main');
     $qb->distinct()->select('d.id')->join('main.attributes', 'a')->join('a.definition', 'd', null, null, 'd.id')->where('main = :main')->setParameter('main', $entity);
     $definitions = $qb->getQuery()->getScalarResult();
     $ids = array_map('current', $definitions);
     foreach ($schema->getDefinitions() as $definition) {
         if (!in_array($definition->getId(), $ids)) {
             $attribute = new Attribute();
             $attribute->setDefinition($definition);
             $entity->addAttribute($attribute);
         }
     }
     if ($uow->getEntityState($entity) == UnitOfWork::STATE_MANAGED) {
         $em->persist($entity);
         $em->flush($entity);
     }
 }
开发者ID:jvahldick,项目名称:AttributeBundle,代码行数:30,代码来源:AttributeCreatorListener.php


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