當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。