/** * adds a type. * * @param BlockPropertyType $type */ public function addType(BlockPropertyType $type) { $this->types[$type->getName()] = $type; }
private function createBlockProperty(BlockMetadata $property, StructureInterface $structure = null) { $blockProperty = new BlockProperty($property->getName(), ['title' => $property->title, 'info_text' => $property->description], $property->getDefaultComponentName(), $property->isRequired(), $property->isLocalized(), $property->getMaxOccurs(), $property->getMinOccurs(), $property->getParameters(), [], $property->getColspan()); $blockProperty->setStructure($structure); foreach ($property->getComponents() as $component) { $blockPropertyType = new BlockPropertyType($component->getName(), ['title' => $component->title, 'info_text' => $component->description]); foreach ($component->getChildren() as $property) { $blockPropertyType->addChild($this->createProperty($property, $structure)); } $blockProperty->addType($blockPropertyType); } return $blockProperty; }
protected function prepareMultipleBlockProperty() { $this->blockProperty = new BlockProperty('block1', '', 'type1', false, true, 10, 1); $type1 = new BlockPropertyType('type1', ''); $type1->addChild(new Property('title', '', 'text_line', false, true)); $type1->addChild(new Property('article', '', 'text_area')); $this->blockProperty->addType($type1); $this->subBlockProperty = new BlockProperty('sub-block', '', 'subType1', false, true); $subType1 = new BlockPropertyType('subType1', ''); $subType1->addChild(new Property('title', '', 'text_line', false, true)); $subType1->addChild(new Property('article', '', 'text_area', false, true)); $this->subBlockProperty->addType($subType1); $type1->addChild($this->subBlockProperty); $type2 = new BlockPropertyType('type2', ''); $type2->addChild(new Property('name', '', 'text_line', false, true)); $this->blockProperty->addType($type2); }