/** * 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 || !$event->getOption('load_shadow_content')) { return; } $node = $event->getNode(); $locale = $this->inspector->getOriginalLocale($document); $shadowLocaleEnabled = $this->getShadowLocaleEnabled($node, $locale); $document->setShadowLocaleEnabled($shadowLocaleEnabled); if (!$shadowLocaleEnabled) { return; } $shadowLocale = $this->getShadowLocale($node, $locale); $document->setShadowLocale($shadowLocale); $event->setLocale($shadowLocale); $document->setLocale($shadowLocale); }
/** * {@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); }
/** * {@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); }