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


PHP Event\LifecycleEventArgs类代码示例

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


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

示例1: prePersist

 /**
  * @param LifecycleEventArgs $event
  */
 public function prePersist(LifecycleEventArgs $event)
 {
     $document = $event->getDocument();
     $className = get_class($document);
     $generateAnnotations = $this->annotationReader->getClassAnnotation(new \ReflectionClass($className), 'OpenOrchestra\\Mapping\\Annotations\\Document');
     if (!is_null($generateAnnotations)) {
         $repository = $this->container->get($generateAnnotations->getServiceName());
         $getSource = $generateAnnotations->getSource($document);
         $getGenerated = $generateAnnotations->getGenerated($document);
         $setGenerated = $generateAnnotations->setGenerated($document);
         $testMethod = $generateAnnotations->getTestMethod();
         if ($testMethod === null && $repository instanceof FieldAutoGenerableRepositoryInterface) {
             $testMethod = 'testUniquenessInContext';
         }
         if (is_null($document->{$getGenerated}())) {
             $source = $document->{$getSource}();
             $source = Inflector::tableize($source);
             $sourceField = $this->suppressSpecialCharacterHelper->transform($source);
             $generatedField = $sourceField;
             $count = 1;
             while ($repository->{$testMethod}($generatedField)) {
                 $generatedField = $sourceField . '-' . $count;
                 $count++;
             }
             $document->{$setGenerated}($generatedField);
         }
     }
 }
开发者ID:open-orchestra,项目名称:open-orchestra-model-bundle,代码行数:31,代码来源:GenerateIdListener.php

示例2: preUpdate

 /**
  * @param LifecycleEventArgs $event
  */
 public function preUpdate(LifecycleEventArgs $event)
 {
     if (!($object = $event->getDocument()) instanceof ContentInterface || in_array($object->getContentId(), $this->contentManaged)) {
         return;
     }
     $this->contentManaged[] = $object->getContentId();
     $contents = $this->getContentRepository()->findByContentId($object->getContentId());
     $contentType = $this->getContentTypeRepository()->findOneByContentTypeIdInLastVersion($object->getContentType());
     /** @var ContentInterface $content */
     foreach ($contents as $content) {
         if ($content != $object) {
             foreach ($this->immutableData as $immutableData) {
                 $getter = $this->generateGetter($immutableData, $object);
                 $setter = 'set' . ucfirst($immutableData);
                 $content->{$setter}($object->{$getter}());
             }
             /** @var FieldTypeInterface $field */
             foreach ($contentType->getFields() as $field) {
                 if (!$field->isTranslatable()) {
                     $contentAttribute = $this->getContentAttribute($content, $field->getFieldId());
                     $contentAttribute->setValue($object->getAttributeByName($field->getFieldId())->getValue());
                 }
             }
         }
         $event->getDocumentManager()->flush($content);
     }
 }
开发者ID:open-orchestra,项目名称:open-orchestra-model-bundle,代码行数:30,代码来源:UpdateNonTranslatableContentFieldsListener.php

示例3: preUpdate

 public function preUpdate(LifecycleEventArgs $args)
 {
     $document = $args->getDocument();
     // perhaps you only want to act on some "Product" document
     if ($document instanceof Project) {
         $dm = $args->getDocumentManager();
         $document->setDateUpdated(new \DateTime("now"));
         $class = $dm->getClassMetadata("Zeega\\DataBundle\\Document\\Project");
         if ($args->hasChangedField("tags")) {
             $update = true;
             $oldTags = $args->getOldValue('tags');
             foreach ($oldTags as $tag) {
                 $name = $tag->getName();
                 $id = $tag->getId();
                 if ($name == 'homepage' && $id !== null) {
                     $update = false;
                     break;
                 }
             }
             if ($update === true) {
                 $document->setDateTagsUpdated(new \DateTime("now"));
             }
         }
         $dm->getUnitOfWork()->recomputeSingleDocumentChangeSet($class, $document);
     }
 }
开发者ID:holtchesley,项目名称:Zeega,代码行数:26,代码来源:DateUpdateListener.php

示例4: preRemove

 public function preRemove(LifecycleEventArgs $args)
 {
     $dm = $args->getDocumentManager();
     $currentDocument = $args->getDocument();
     $currentDocumentClass = get_class($currentDocument);
     $isRefExists = FALSE;
     $documentClassNames = $dm->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
     foreach ($documentClassNames as $documentClassName) {
         try {
             $cm = $dm->getClassMetadata($documentClassName);
             foreach ($cm->getAssociationNames() as $associationName) {
                 if ($currentDocumentClass == $cm->getAssociationTargetClass($associationName) || is_subclass_of($currentDocumentClass, $cm->getAssociationTargetClass($associationName))) {
                     $searchObj = $dm->getRepository($documentClassName)->findOneBy(array($associationName . '.$id' => new \MongoId($currentDocument->getId())));
                     if ($searchObj) {
                         $isRefExists = TRUE;
                     }
                 }
             }
         } catch (\Exception $e) {
         }
     }
     if ($isRefExists) {
         throw new \Exception('ref_erro');
     }
 }
开发者ID:agalchenko,项目名称:NitraThemeBundle,代码行数:25,代码来源:OdmRemoveListener.php

示例5: postLoad

 /**
  * @param LifecycleEventArgs $eventArgs
  * @since 0.28
  */
 public function postLoad(LifecycleEventArgs $eventArgs)
 {
     $entity = $eventArgs->getDocument();
     if ($entity instanceof AttachableEntityInterface) {
         $this->injectAttachableEntityManager($entity);
     }
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:11,代码来源:RepositoryEventsSubscriber.php

示例6: setPath

 /**
  * @param LifecycleEventArgs $eventArgs
  */
 public function setPath(LifecycleEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     if ($document instanceof NodeInterface && false === $document->isDeleted()) {
         $nodeRepository = $this->container->get('open_orchestra_model.repository.node');
         $nodeId = $document->getNodeId();
         $siteId = $document->getSiteId();
         $language = $document->getLanguage();
         $path = '';
         $parentNode = $nodeRepository->findInLastVersion($document->getParentId(), $document->getLanguage(), $siteId);
         if ($parentNode instanceof NodeInterface) {
             $path = $parentNode->getPath() . '/';
         }
         $path .= $nodeId;
         if ($path != $document->getPath()) {
             $document->setPath($path);
             $this->nodes[] = $document;
             $childNodes = $nodeRepository->findSubTreeByPath($document->getPath(), $siteId, $language);
             foreach ($childNodes as $childNode) {
                 $this->nodes[] = $childNode;
                 $childNode->setPath(preg_replace('/' . preg_quote($document->getPath(), '/') . '(.*)/', $path . '$1', $childNode->getPath()));
             }
         }
     }
 }
开发者ID:open-orchestra,项目名称:open-orchestra-model-bundle,代码行数:28,代码来源:GeneratePathListener.php

示例7: prePersist

 /**
  * @param LifecycleEventArgs $args
  */
 public function prePersist($args)
 {
     $object = $args->getDocument();
     if ($object instanceof UserInterface) {
         $this->updateUserFields($object);
     }
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:10,代码来源:UserListener.php

示例8: postLoad

 /**
  * Hydrates the given node
  * @param LifecycleEventArgs $eventArgs
  */
 public function postLoad(LifecycleEventArgs $eventArgs)
 {
     if ($eventArgs->getDocument() instanceof Node) {
         /*
          * Loading users and group inside the current Node
          * Using an event suscriber to allow these objects to come from many places
          */
         $node = $eventArgs->getDocument();
         $groupId = $node->getGroupId();
         /*
          * If netBS
          *
         if(!is_null($groupId))
             $node->setGroup($this->em->getRepository('AppBundle:Groupe')->find($groupId));
         
         
         foreach($node->getUsersId() as $id)
             $node->addUser($this->em->getRepository('InterneSecurityBundle:User')->find($id));
         */
         /*
          * If colibri
          */
         foreach ($node->getUsersId() as $id) {
             $user = $eventArgs->getDocumentManager()->getRepository('ColibriUserBundle:User')->find($id);
             $node->addUser($user);
         }
     }
 }
开发者ID:sysmoh,项目名称:colibri,代码行数:32,代码来源:NodeListener.php

示例9: preUpdate

 public function preUpdate(LifecycleEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     if (!$document instanceof SearchableEntityInterface) {
         return;
     }
     $dm = $eventArgs->getDocumentManager();
     $uow = $dm->getUnitOfWork();
     $changeset = $uow->getDocumentChangeset($document);
     $filter = $this->getKeywordsFilter();
     $keywords = array();
     $mustUpdate = false;
     foreach ($document->getSearchableProperties() as $name) {
         if (isset($changeset[$name])) {
             $mustUpdate = true;
             break;
         }
     }
     if (!$mustUpdate) {
         return;
     }
     $keywords = $filter->filter($document);
     $document->setKeywords($keywords);
     $uow->recomputeSingleDocumentChangeSet($dm->getClassMetadata(get_class($document)), $document);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:25,代码来源:GenerateSearchKeywordsListener.php

示例10: postUpdate

 public function postUpdate(LifecycleEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     if ($document instanceof MODM67EmbeddedObject) {
         $document->postUpdate = true;
     }
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:7,代码来源:MODM67Test.php

示例11: postRemove

 public function postRemove(LifecycleEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     if ($document instanceof $this->objectClass) {
         $this->removeIfScheduled($document);
     }
 }
开发者ID:niborb,项目名称:FOQElasticaBundle,代码行数:7,代码来源:Listener.php

示例12: postPersist

 /**
  * @param LifecycleEventArgs $args
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     $entity = $args->getDocument();
     try {
         $this->solrFacade->addDocument($entity);
     } catch (\RuntimeException $e) {
     }
 }
开发者ID:rmzamora,项目名称:SolrBundle,代码行数:11,代码来源:AddDocumentListener.php

示例13: postUpdate

 /**
  * @param LifecycleEventArgs $event
  */
 public function postUpdate(LifecycleEventArgs $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof ChannelableInterface) {
         return;
     }
     $this->process($document, 'add');
 }
开发者ID:integratedfordevelopers,项目名称:integrated-channel-bundle,代码行数:11,代码来源:ChannelDistributionListener.php

示例14: postPersist

 /**
  * @param LifecycleEventArgs $args
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     $document = $args->getDocument();
     if ($document instanceof ArticleSubmissionProgress) {
         $aclManager = $this->container->get('problematic.acl_manager');
         $aclManager->on($document)->permit(MaskBuilder::MASK_OWNER)->save();
     }
 }
开发者ID:necatikartal,项目名称:ojs,代码行数:11,代码来源:AclOdmListener.php

示例15: postUpdate

 /**
  * @param LifecycleEventArgs $args
  */
 public function postUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getDocument();
     try {
         $this->solr->updateDocument($entity);
     } catch (\RuntimeException $e) {
     }
 }
开发者ID:wizbit,项目名称:SolrBundle,代码行数:11,代码来源:UpdateDocumentListener.php


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