コード例 #1
0
 /**
  * @param AbstractMappingEvent $event
  *
  * @throws DocumentManagerException
  */
 public function handleLocale(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof LocaleBehavior) {
         return;
     }
     $event->getAccessor()->set('locale', $this->registry->getLocaleForDocument($document));
 }
コード例 #2
0
ファイル: WebspaceSubscriber.php プロジェクト: Silwereth/sulu
 /**
  * @param AbstractMappingEvent $event
  */
 public function handleWebspace(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof WebspaceBehavior) {
         return;
     }
     $webspaceName = $this->inspector->getWebspace($document);
     $event->getAccessor()->set('webspaceName', $webspaceName);
 }
コード例 #3
0
 /**
  * @param AbstractMappingEvent $event
  *
  * @throws DocumentManagerException
  */
 public function handleNodeName(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof NodeNameBehavior) {
         return;
     }
     $node = $event->getNode();
     $accessor = $event->getAccessor();
     $accessor->set('nodeName', $node->getName());
 }
コード例 #4
0
 /**
  * @param AbstractMappingEvent $event
  *
  * @throws DocumentManagerException
  */
 public function handleUuid(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof UuidBehavior) {
         return;
     }
     $node = $event->getNode();
     $accessor = $event->getAccessor();
     $accessor->set('uuid', $node->getIdentifier());
 }
コード例 #5
0
ファイル: OrderSubscriber.php プロジェクト: kriswillis/sulu
 /**
  * Adds the order to the document.
  *
  * @param AbstractMappingEvent $event
  */
 public function handleHydrate(AbstractMappingEvent $event)
 {
     if (false == $this->supports($event->getDocument())) {
         return;
     }
     $node = $event->getNode();
     $order = $node->getPropertyValueWithDefault($this->encoder->systemName(self::FIELD), null);
     $event->getAccessor()->set('suluOrder', $order);
 }
コード例 #6
0
 /**
  * @param AbstractMappingEvent|HydrateEvent $event
  *
  * @throws \Sulu\Component\DocumentManager\Exception\DocumentManagerException
  */
 public function doHydrate(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     $webspaceName = $this->inspector->getWebspace($document);
     $event->getAccessor()->set('webspaceName', $webspaceName);
 }
コード例 #7
0
ファイル: StructureSubscriber.php プロジェクト: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public function handleHydrate(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$this->supportsBehavior($document)) {
         return;
     }
     $node = $event->getNode();
     $propertyName = $this->getStructureTypePropertyName($document, $event->getLocale());
     $structureType = $node->getPropertyValueWithDefault($propertyName, null);
     $rehydrate = $event->getOption('rehydrate');
     if (!$structureType && $rehydrate) {
         $structureType = $this->getDefaultStructureType($document);
     }
     $document->setStructureType($structureType);
     if (false === $event->getOption('load_ghost_content', false)) {
         if ($this->inspector->getLocalizationState($document) === LocalizationState::GHOST) {
             $structureType = null;
         }
     }
     $container = $this->getStructure($document, $structureType, $rehydrate);
     // Set the property container
     $event->getAccessor()->set('structure', $container);
 }
コード例 #8
0
ファイル: StructureSubscriber.php プロジェクト: ollietb/sulu
 /**
  * {@inheritdoc}
  */
 public function handleHydrate(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof StructureBehavior) {
         return;
     }
     $node = $event->getNode();
     $propertyName = $this->getStructureTypePropertyName($document, $event->getLocale());
     $value = $node->getPropertyValueWithDefault($propertyName, null);
     $document->setStructureType($value);
     if (false === $event->getOption('load_ghost_content', false)) {
         if ($this->inspector->getLocalizationState($document) === LocalizationState::GHOST) {
             $value = null;
         }
     }
     if ($value) {
         $container = $this->createStructure($document);
     } else {
         $container = new Structure();
     }
     // Set the property container
     $event->getAccessor()->set('structure', $container);
 }
コード例 #9
0
 /**
  * @param AbstractMappingEvent $event
  *
  * @throws DocumentManagerException
  */
 public function handleHydrate(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof BlameBehavior) {
         return;
     }
     $node = $event->getNode();
     $locale = $event->getLocale();
     $accessor = $event->getAccessor();
     $accessor->set(self::CREATOR, $this->getCreator($node, $locale));
     $accessor->set(self::CHANGER, $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::CHANGER, $locale), null));
 }