/** * Handles persist event of document manager. * * @param AbstractMappingEvent $event */ public function copyShadowProperties(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } if (!$event->getDocument()->isShadowLocaleEnabled()) { $this->copyToShadows($event->getDocument(), $event->getNode()); } else { $this->copyFromShadow($event->getDocument(), $event->getNode()); } }
/** * @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)); }
/** * @param AbstractMappingEvent $event */ public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $this->doHydrate($event); }
/** * @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); }
/** * @param HydrateEvent $event */ public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof TitleBehavior) { return; } $title = $this->getTitle($document); $document->setTitle($title); }
/** * @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()); }
/** * @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()); }
/** * @param HydrateEvent $event */ public function doHydrate(AbstractMappingEvent $event) { $node = $event->getNode(); $document = $event->getDocument(); $targetNode = $node->getPropertyValueWithDefault($this->encoder->systemName(self::DOCUMENT_TARGET_FIELD), null); $targetDocument = null; if ($targetNode) { $targetDocument = $this->proxyFactory->createProxyForNode($document, $targetNode); } $document->setTargetDocument($targetDocument); }
/** * @param AbstractMappingEvent $event */ public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $node = $event->getNode(); $property = $this->getResourceSegmentProperty($document); $originalLocale = $this->inspector->getOriginalLocale($document); $segment = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName($property->getName(), $originalLocale), ''); $document->setResourceSegment($segment); }
/** * @param AbstractMappingEvent $event */ public function doHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if ($document instanceof RedirectTypeBehavior && $document->getRedirectType() !== RedirectType::NONE) { return; } $node = $event->getNode(); $property = $this->getResourceSegmentProperty($document); $originalLocale = $this->inspector->getOriginalLocale($document); $segment = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName($property->getName(), $originalLocale), ''); $document->setResourceSegment($segment); }
/** * Update the locale to the shadow locale, if it is enabled. * * Note that this should happen before the fallback locale has been resolved * * @param HydrateEvent $event */ public function doHydrate(AbstractMappingEvent $event) { $node = $event->getNode(); $locale = $event->getLocale(); $document = $event->getDocument(); $shadowLocaleEnabled = $this->getShadowLocaleEnabled($node, $locale); $document->setShadowLocaleEnabled($shadowLocaleEnabled); if (!$shadowLocaleEnabled) { return; } $document->setShadowLocale($this->getShadowLocale($node, $locale)); $shadowLocale = $this->getShadowLocale($node, $locale); $this->registry->updateLocale($document, $shadowLocale, $locale); $event->setLocale($shadowLocale); }
/** * Sets the title on the node from the value in the document. * * @param PersistEvent $event */ public function setTitleOnNode(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } if ($document instanceof LocalizedTitleBehavior) { if (!$event->getLocale()) { return; } $event->getNode()->setProperty($this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()), $document->getTitle()); } else { $event->getNode()->setProperty($this->propertyEncoder->contentName(static::PROPERTY_NAME), $document->getTitle()); } }
/** * @param AbstractMappingEvent $event */ public function doHydrate(AbstractMappingEvent $event) { $node = $event->getNode(); $document = $event->getDocument(); $redirectType = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::REDIRECT_TYPE_FIELD, $event->getLocale()), RedirectType::NONE); $document->setRedirectType($redirectType); if ($redirectType === RedirectType::INTERNAL) { $internalNode = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::INTERNAL_FIELD, $event->getLocale()), null); if ($internalNode) { $document->setRedirectTarget($this->proxyFactory->createProxyForNode($document, $internalNode)); } } if ($redirectType === RedirectType::EXTERNAL) { $externalUrl = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::EXTERNAL_FIELD, $event->getLocale()), null); $document->setRedirectExternal($externalUrl); } }
/** * Update the locale to the shadow locale, if it is enabled. * * Note that this should happen before the fallback locale has been resolved * * @param AbstractMappingEvent $event */ public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof ShadowLocaleBehavior) { return; } $node = $event->getNode(); $locale = $event->getLocale(); $shadowLocaleEnabled = $this->getShadowLocaleEnabled($node, $locale); $document->setShadowLocaleEnabled($shadowLocaleEnabled); if (!$shadowLocaleEnabled) { return; } $shadowLocale = $this->getShadowLocale($node, $locale); $document->setShadowLocale($shadowLocale); $this->registry->updateLocale($document, $shadowLocale, $locale); $event->setLocale($shadowLocale); }
/** * {@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); }
private function handleRegister(AbstractMappingEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $locale = $event->getLocale(); if ($this->documentRegistry->hasDocument($document)) { $this->documentRegistry->updateLocale($document, $locale); return; } $this->documentRegistry->registerDocument($document, $node, $locale); }
/** * @param HydrateEvent $event */ public function doHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); $title = $this->getTitle($document); $document->setTitle($title); }
/** * 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); }
/** * @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)); }
/** * {@inheritdoc} */ public function saveShadowProperties(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof ShadowLocaleBehavior) { return; } if (!$event->getLocale()) { return; } if ($document->isShadowLocaleEnabled()) { $this->validateShadow($document); } $event->getNode()->setProperty($this->encoder->localizedSystemName(self::SHADOW_ENABLED_FIELD, $event->getLocale()), $document->isShadowLocaleEnabled() ?: null); $event->getNode()->setProperty($this->encoder->localizedSystemName(self::SHADOW_LOCALE_FIELD, $event->getLocale()), $document->getShadowLocale()); }
/** * @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); }
private function hydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $locale = $this->inspector->getLocale($document); $webspaceName = $this->inspector->getWebspace($document); $structureType = $document->getStructureType(); if (null === $structureType) { return; } $prefix = $this->namespaceRegistry->getPrefix('extension_localized'); $extensionContainer = new ManagedExtensionContainer($structureType, $this->extensionManager, $node, $locale, $prefix, $this->internalPrefix, $webspaceName); $document->setExtensionsData($extensionContainer); }
/** * @param HydrateEvent $event */ public function doHydrate(AbstractMappingEvent $event) { $node = $event->getNode(); $value = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::FIELD, $event->getLocale()), []); $event->getDocument()->setNavigationContexts($value); }
/** * {@inheritdoc} */ public function saveStructureData(AbstractMappingEvent $event) { // Set the structure type $document = $event->getDocument(); if (!$this->supportsBehavior($document)) { return; } if (!$document->getStructureType()) { return; } if (!$event->getLocale()) { return; } $node = $event->getNode(); $locale = $event->getLocale(); $options = $event->getOptions(); $this->mapContentToNode($document, $node, $locale, $options['ignore_required']); $node->setProperty($this->getStructureTypePropertyName($document, $locale), $document->getStructureType()); }