Inheritance: extends Sulu\Component\Content\Compat\Property, implements Sulu\Component\Content\Compat\Block\BlockPropertyInterface
Exemple #1
0
 public function testSetValue()
 {
     $data = [['type' => 'test', 'title' => 'my title', 'description' => 'my description']];
     $blockProperty = new BlockProperty('block', [], 'test');
     $blockPropertyType = $this->prophesize(BlockPropertyType::class);
     $blockPropertyType->getName()->willReturn('test');
     $blockProperty->addType($blockPropertyType->reveal());
     $blockPropertyValue = $this->prophesize(PropertyValue::class);
     $blockPropertyValue->setValue($data)->shouldBeCalled();
     $blockPropertyValue->getValue()->willReturn(null);
     $blockProperty->setPropertyValue($blockPropertyValue->reveal());
     $childProperty1 = $this->prophesize(PropertyInterface::class);
     $childProperty1->getName()->willReturn('title');
     $childProperty1->setValue($data[0]['title'])->shouldBeCalled();
     $childProperty2 = $this->prophesize(PropertyInterface::class);
     $childProperty2->getName()->willReturn('description');
     $childProperty2->setValue($data[0]['description'])->shouldBeCalled();
     $blockPropertyType->getChildProperties()->willReturn([$childProperty1->reveal(), $childProperty2->reveal()]);
     $blockProperty->setValue($data);
 }
 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;
 }