setStructure() public method

public setStructure ( Sulu\Component\Content\Compat\StructureInterface $structure )
$structure Sulu\Component\Content\Compat\StructureInterface
Exemplo n.º 1
0
 private function getStructureMock($name, $rlp = true)
 {
     $structureMock = $this->getMockForAbstractClass('\\Sulu\\Component\\Content\\Compat\\Structure\\Page', [$name, 'asdf', 'asdf', 2400]);
     $method = new ReflectionMethod(get_class($structureMock), 'addChild');
     $method->setAccessible(true);
     $property = new Property('title', '', 'text_line', true, true, 1, 1, []);
     $property->setStructure($structureMock);
     $method->invokeArgs($structureMock, [$property]);
     if ($rlp) {
         $property = new Property('url', '', 'resource_locator', true, true, 1, 1, [], [new PropertyTag('sulu.rlp', 1)]);
         $property->setStructure($structureMock);
         $method->invokeArgs($structureMock, [$property]);
     }
     return $structureMock;
 }
Exemplo n.º 2
0
 /**
  * Create a new property.
  *
  * @param Item $item
  *
  * @return 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;
 }