Sulu\Component\Content\Metadata\BlockMetadata::getComponentByName PHP Method

getComponentByName() public method

public getComponentByName ( $name ) : ComponentMetadata
$name
return ComponentMetadata
    public function getComponentByName($name)
    {
        foreach ($this->components as $component) {
            if ($component->getName() == $name) {
                return $component;
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Creates and Returns a property-array for content-type Block.
  *
  * @param BlockMetadata $property
  * @param PropertyValue $propertyValue
  * @param $format
  *
  * @return array
  */
 protected function getBlockPropertyData(BlockMetadata $property, $propertyValue, $format)
 {
     $children = [];
     $blockDataList = $this->contentExportManager->export($property->getType(), $propertyValue);
     foreach ($blockDataList as $blockData) {
         $blockType = $blockData['type'];
         $block = $this->getPropertiesContentData($property->getComponentByName($blockType)->getChildren(), $blockData, $format);
         $block['type'] = $this->createProperty('type', $blockType, $this->contentExportManager->getOptions($property->getType(), $format), $property->getType() . '_type');
         $children[] = $block;
     }
     return $this->createProperty($property->getName(), null, $this->contentExportManager->getOptions($property->getType(), $format), $property->getType(), $children);
 }