Inheritance: implements Sulu\Component\Content\Document\Structure\StructureInterface
Ejemplo n.º 1
0
 /**
  * @param JsonSerializationVisitor $visitor
  * @param NodeInterface            $nodeInterface
  * @param array                    $type
  * @param Context                  $context
  */
 public function doDeserialize(JsonDeserializationVisitor $visitor, array $data, array $type, Context $context)
 {
     $container = new Structure();
     foreach ($data as $key => $value) {
         $container->getProperty($key)->setValue($value);
     }
     return $container;
 }
Ejemplo n.º 2
0
 /**
  * It should throw an exception if the property is required but the value is null.
  *
  * @expectedException Sulu\Component\Content\Exception\MandatoryPropertyException
  */
 public function testThrowExceptionPropertyRequired()
 {
     $document = new TestContentDocument($this->structure->reveal());
     $document->setStructureType('foobar');
     $this->persistEvent->getDocument()->willReturn($document);
     // map the structure type
     $this->persistEvent->getLocale()->willReturn('fr');
     // map the content
     $this->inspector->getStructureMetadata($document)->willReturn($this->structureMetadata->reveal());
     $this->inspector->getWebspace($document)->willReturn('webspace');
     $this->structureMetadata->getProperties()->willReturn(['prop1' => $this->structureProperty->reveal()]);
     $this->structureProperty->isRequired()->willReturn(true);
     $this->structure->getProperty('prop1')->willReturn($this->propertyValue->reveal());
     $this->propertyValue->getValue()->willReturn(null);
     $this->structureMetadata->getName()->willReturn('test');
     $this->structureMetadata->getResource()->willReturn('/path/to/resource.xml');
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }