Sulu\Component\Content\Compat\Structure\LegacyPropertyFactory::createTranslatedProperty PHP Méthode

createTranslatedProperty() public méthode

Create a new "translated" property.
public createTranslatedProperty ( object $property, string $locale, Sulu\Component\Content\Compat\StructureInterface $structure = null ) : Sulu\Component\Content\Compat\PropertyInterface
$property object
$locale string
$structure Sulu\Component\Content\Compat\StructureInterface
Résultat Sulu\Component\Content\Compat\PropertyInterface
    public function createTranslatedProperty($property, $locale, StructureInterface $structure = null)
    {
        if ($property instanceof ItemMetadata) {
            $property = $this->createProperty($property, $structure);
        }
        $property = new TranslatedProperty($property, $locale, $this->namespaceRegistry->getPrefix('content_localized'));
        return $property;
    }

Usage Example

Exemple #1
0
 /**
  * {@inheritDoc}
  */
 public function getProperty($name)
 {
     $this->init();
     if (isset($this->properties[$name])) {
         return $this->properties[$name];
     }
     if (!$this->node) {
         $this->node = $this->inspector->getNode($this->document);
     }
     $structureProperty = $this->structureMetadata->getProperty($name);
     $contentTypeName = $structureProperty->getType();
     $bridge = new StructureBridge($this->structureMetadata, $this->inspector, $this->legacyPropertyFactory, $this->document);
     if ($structureProperty->isLocalized()) {
         $locale = $this->inspector->getLocale($this->document);
         $property = $this->legacyPropertyFactory->createTranslatedProperty($structureProperty, $locale, $bridge);
     } else {
         $property = $this->legacyPropertyFactory->createProperty($structureProperty);
     }
     $this->legacyProperties[$name] = $property;
     $property->setStructure($bridge);
     $contentType = $this->contentTypeManager->get($contentTypeName);
     $contentType->read($this->node, $property, null, null, null);
     $valueProperty = new PropertyValue($name, $property->getValue());
     $this->properties[$name] = $valueProperty;
     return $valueProperty;
 }
All Usage Examples Of Sulu\Component\Content\Compat\Structure\LegacyPropertyFactory::createTranslatedProperty