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

createProperty() public méthode

Create a new property.
public createProperty ( ItemMetadata $property, Sulu\Component\Content\Compat\StructureInterface $structure = null ) : Sulu\Component\Content\Compat\PropertyInterface
$property Sulu\Component\Content\Metadata\ItemMetadata
$structure Sulu\Component\Content\Compat\StructureInterface
Résultat Sulu\Component\Content\Compat\PropertyInterface $property
    public function createProperty(ItemMetadata $property, StructureInterface $structure = null)
    {
        if ($property instanceof SectionMetadata) {
            return $this->createSectionProperty($property, $structure);
        }
        if ($property instanceof BlockMetadata) {
            return $this->createBlockProperty($property, $structure);
        }
        if (null === $property->getType()) {
            throw new \RuntimeException(sprintf('Property name "%s" has no type.', $property->name));
        }
        $parameters = $this->convertArrayToParameters($property->getParameters());
        $propertyBridge = new LegacyProperty($property->getName(), ['title' => $property->title, 'info_text' => $property->description, 'placeholder' => $property->placeholder], $property->getType(), $property->isRequired(), $property->isLocalized(), $property->getMaxOccurs(), $property->getMinOccurs(), $parameters, [], $property->getColspan());
        foreach ($property->tags as $tag) {
            $propertyBridge->addTag(new PropertyTag($tag['name'], $tag['priority'], $tag['attributes']));
        }
        $propertyBridge->setStructure($structure);
        return $propertyBridge;
    }

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::createProperty