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


PHP LifecycleEventArgs::getDocument方法代码示例

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


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

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

示例2: postLoad

 public function postLoad(\Doctrine\ODM\MongoDB\Event\LifecycleEventArgs $eventArgs)
 {
     if (!$eventArgs->getDocument() instanceof \Bpi\ApiBundle\Domain\Entity\Author) {
         return;
     }
     $author = $eventArgs->getDocument();
     $author->loadAgency($eventArgs->getDocumentManager()->getRepository('BpiApiBundle:Aggregate\\Agency'));
 }
开发者ID:rimi-itk,项目名称:bpi-web-service,代码行数:8,代码来源:EventListener.php

示例3: postRemove

 public function postRemove(LifecycleEventArgs $eventArgs)
 {
     if ($eventArgs->getDocument() instanceof Image) {
         /* @var Image $image */
         $image = $eventArgs->getDocument();
         try {
             $this->imageManager->delete($image, 'uploads');
         } catch (FileException $e) {
             $this->logger->error('PostRemoveListener: Error while deleting image ' . $image->getFileName() . ' Error: ' . $e->getMessage());
         }
     }
 }
开发者ID:jahller,项目名称:streetartlas,代码行数:12,代码来源:PostRemoveListener.php

示例4: postUpdate

 public function postUpdate(LifecycleEventArgs $arg)
 {
     if (!$this->container->isScopeActive('request')) {
         return;
     }
     if (!$this->container->get('security.context')->getToken()->isAuthenticated()) {
         return;
     }
     if ($arg->getDocument() instanceof Document\Article) {
         if ($arg->getDocument()->wereTranslationsModified()) {
             $this->notifyModification($arg->getDocument(), $arg->getDocumentManager());
         }
     }
 }
开发者ID:Cohros,项目名称:KnowledgeBase,代码行数:14,代码来源:UserActionListener.php

示例5: postRemove

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

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

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

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

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

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

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

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

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

示例14: postUpdate

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

示例15: prePersist

 /**
  * Set object creator & updater
  *
  * @param LifecycleEventArgs $args The event arguments
  */
 public function prePersist(LifecycleEventArgs $args)
 {
     $obj = $args->getDocument();
     $blameable = $this->driver->getBlameableAnnotation($obj);
     if (null !== $blameable) {
         $this->updateEntity($obj, $blameable, true);
     }
 }
开发者ID:rafaelgou,项目名称:PSSDoctrineExtensionsBundle,代码行数:13,代码来源:BlameableListener.php


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