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


PHP Event\LifecycleEventArgs类代码示例

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


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

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

示例2: prePersist

 public function prePersist(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if ($object instanceof UuidAwareInterface and !$object->getId()) {
         $object->setId((new UuidGenerator())->generate($event->getEntityManager(), $object));
     }
 }
开发者ID:liverbool,项目名称:dos-resource-bundle,代码行数:7,代码来源:UuidGeneratorListener.php

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

示例4: postLoad

 /**
  * After entity with reminders was loaded, load reminders
  *
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof RemindableInterface) {
         $this->getReminderManager()->loadReminders($entity);
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:12,代码来源:ReminderListener.php

示例5: postLoad

 /**
  * Post load
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof TranslatableInterface) {
         $entity->setLocale($this->locale);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:11,代码来源:AddLocaleListener.php

示例6: postLoad

 /**
  * @param LifecycleEventArgs $event
  */
 public function postLoad(LifecycleEventArgs $event)
 {
     $settings = $event->getObject();
     if ($settings instanceof SettingsInterface) {
         $this->reverseTransform($settings);
     }
 }
开发者ID:TeamNovatek,项目名称:Sylius,代码行数:10,代码来源:ParameterTransformerListener.php

示例7: postLoadHandler

 /**
  * @ORM\PostLoad
  *
  * @param \Venne\Security\User $user
  * @param \Doctrine\ORM\Event\LifecycleEventArgs $event
  */
 public function postLoadHandler(User $user, LifecycleEventArgs $event)
 {
     $em = $event->getEntityManager();
     $user->setExtendedUserCallback(function () use($em, $user) {
         return $em->getRepository($user->getClass())->findOneBy(array('user' => $user->id));
     });
 }
开发者ID:venne,项目名称:venne,代码行数:13,代码来源:ExtendedUserListener.php

示例8: postLoad

 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     if ($entity instanceof ServiceAwareEntityInterface) {
         $entity->setServiceLocator($this->serviceManager);
     }
 }
开发者ID:fousheezy,项目名称:common,代码行数:7,代码来源:ServiceAwareEntity.php

示例9: checkBadWords

 /**
  * @param LifecycleEventArgs $args
  * @return bool
  * @throws \Exception
  */
 public function checkBadWords(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if (!$entity instanceof BadWordDetectorInterface) {
         return true;
     }
     $badWords = $args->getEntityManager()->getRepository('RenowazeBundle:BadWord')->findAll();
     /** @var BadWordDetector $annotationParams */
     $annotationParams = $this->reader->getClassAnnotation(new \ReflectionClass($entity), 'RenowazeBundle\\Annotation\\BadWordDetector');
     foreach ($annotationParams->fields as $field) {
         $methodName = 'get' . ucfirst($field);
         if (!method_exists($entity, $methodName)) {
             throw new \Exception(sprintf('Field "%s" not found in entity "%s"', $methodName, get_class($entity)));
         }
         /** @var BadWord $badWord */
         foreach ($badWords as $badWord) {
             if (strpos($entity->{$methodName}(), $badWord->getWord()) !== false) {
                 $entity->setHasBadWords(true);
                 return true;
             }
         }
     }
     $entity->setHasBadWords(false);
     return true;
 }
开发者ID:reggin,项目名称:BadWordExtension,代码行数:30,代码来源:BadWordDetectorDriver.php

示例10: prePersist

 /**
  * @param LifecycleEventArgs $args
  */
 public function prePersist($args)
 {
     $object = $args->getEntity();
     if ($object instanceof Poll && $object->getCreatedOn() === null) {
         $object->setCreatedOn(new \DateTime());
     }
 }
开发者ID:linestorm,项目名称:poll-component-bundle,代码行数:10,代码来源:PollListener.php

示例11: postPersist

 public function postPersist(LifecycleEventArgs $event)
 {
     /** @var OroEntityManager $em */
     $em = $event->getEntityManager();
     $entity = $event->getEntity();
     $configProvider = $em->getExtendManager()->getConfigProvider();
     $className = get_class($entity);
     if ($configProvider->hasConfig($className)) {
         $config = $configProvider->getConfig($className);
         $schema = $config->get('schema');
         if (isset($schema['relation'])) {
             foreach ($schema['relation'] as $fieldName) {
                 /** @var Config $fieldConfig */
                 $fieldConfig = $configProvider->getConfig($className, $fieldName);
                 if ($fieldConfig->getId()->getFieldType() == 'optionSet' && ($setData = $entity->{Inflector::camelize('get_' . $fieldName)}())) {
                     $model = $configProvider->getConfigManager()->getConfigFieldModel($fieldConfig->getId()->getClassName(), $fieldConfig->getId()->getFieldName());
                     /**
                      * in case of single select field type, should wrap value in array
                      */
                     if ($setData && !is_array($setData)) {
                         $setData = [$setData];
                     }
                     foreach ($setData as $option) {
                         $optionSetRelation = new OptionSetRelation();
                         $optionSetRelation->setData(null, $entity->getId(), $model, $em->getRepository(OptionSet::ENTITY_NAME)->find($option));
                         $em->persist($optionSetRelation);
                         $this->needFlush = true;
                     }
                 }
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:33,代码来源:OptionSetListener.php

示例12: postLoad

    /**
     * @param \Doctrine\ORM\Event\LifecycleEventArgs $eventArgs
     */
    public function postLoad(LifecycleEventArgs $eventArgs)
    {
        $action = $eventArgs->getEntity();
        $className = get_class($action);
        $em = $eventArgs->getEntityManager();
        $metadata = $em->getClassMetadata($className);

        if ($metadata->reflClass->implementsInterface('Redpanda\Bundle\ActivityStreamBundle\Model\ActionInterface')) {

            if ($this->streamableResolver->supports($eventArgs, $action->getActorType())) {
                $actorReflProp = $metadata->reflClass->getProperty('actor');
                $actorReflProp->setAccessible(true);
                $actorReflProp->setValue(
                    $action, $this->streamableResolver->resolve($eventArgs, $action->getActorType(), $action->getActorId())
                );
            }

            if ($this->streamableResolver->supports($eventArgs, $action->getTargetType())) {
                $targetReflProp = $metadata->reflClass->getProperty('target');
                $targetReflProp->setAccessible(true);
                $targetReflProp->setValue(
                    $action, $this->streamableResolver->resolve($eventArgs, $action->getTargetType(), $action->getTargetId())
                );
            }

            if (null !== $action->getActionObjectType() && $this->streamableResolver->supports($eventArgs, $action->getActionObjectType())) {
                $actionObjReflProp = $metadata->reflClass->getProperty('actionObject');
                $actionObjReflProp->setAccessible(true);
                $actionObjReflProp->setValue(
                    $action, $this->streamableResolver->resolve($eventArgs, $action->getActionObjectType(), $action->getActionObjectId())
                );
            }
        }
    }
开发者ID:redpanda,项目名称:ActivityStreamBundle,代码行数:37,代码来源:ActionSubscriber.php

示例13: postLoad

 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof Test) {
         $this->calculateCorrectAnswer($entity);
     }
 }
开发者ID:shitikovkirill,项目名称:MedTestPHP,代码行数:7,代码来源:TestListener.php

示例14: preRemove

 /**
  * @param LifecycleEventArgs $args
  */
 public function preRemove(LifecycleEventArgs $args)
 {
     $file = $args->getEntity();
     if ($file instanceof File && $file->getName() !== null && file_exists($file->getPath())) {
         $this->cacheManager->remove($file->getPath());
     }
 }
开发者ID:syrotchukandrew,项目名称:rainbow,代码行数:10,代码来源:FileCacheRemoveEventSubscriber.php

示例15: postLoadHandler

 /** @ORM\PostLoad */
 public function postLoadHandler(RouteEntity $route, LifecycleEventArgs $event)
 {
     $em = $event->getEntityManager();
     $route->setExtendedRouteCallback(function () use($em, $route) {
         return $em->getRepository($route->getClass())->findOneBy(array('route' => $route->id));
     });
 }
开发者ID:svobodni,项目名称:web,代码行数:8,代码来源:ExtendedRouteListener.php


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