Return the original (requested) locale for this document before
any fallback logic was applied to it.
public getOriginalLocale ( object $document ) : string | ||
$document | object | |
return | string |
/** * @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); }
/** * {@inheritdoc} */ public function getLanguageCode() { if (!$this->document) { return $this->locale; } return $this->inspector->getOriginalLocale($this->getDocument()); }
/** * 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); }
private function doGetProperty($name, $contentTypeName, $locale) { $this->propertyMetadata->getType()->willReturn($contentTypeName); $this->structureMetadata->getProperty($name)->willReturn($this->propertyMetadata); $this->contentTypeManager->get($contentTypeName)->willReturn($this->contentType->reveal()); if ($locale) { $this->propertyFactory->createTranslatedProperty($this->propertyMetadata->reveal(), $locale, Argument::type(StructureBridge::class))->willReturn($this->legacyProperty->reveal()); } else { $this->propertyFactory->createProperty($this->propertyMetadata->reveal(), $locale)->willReturn($this->legacyProperty->reveal()); } $this->inspector->getWebspace($this->document->reveal())->willReturn('sulu_io'); $this->inspector->getOriginalLocale($this->document->reveal())->willReturn($locale); $this->contentType->read($this->node->reveal(), $this->legacyProperty->reveal(), 'sulu_io', $locale, null)->shouldBeCalledTimes(1); $property = $this->structure->getProperty($name); $this->assertInstanceOf(PropertyValue::class, $property); $this->assertEquals($name, $property->getName()); }