Inheritance: implements Sulu\Component\Content\Compat\PropertyInterface
Exemplo n.º 1
0
 /**
  * It should set the structure type and map the content to thethe node.
  */
 public function testPersist()
 {
     $document = new TestContentDocument($this->structure->reveal());
     $document->setStructureType('foobar');
     $this->persistEvent->getDocument()->willReturn($document);
     // map the structure type
     $this->persistEvent->getLocale()->willReturn('fr');
     $this->encoder->contentName('template')->willReturn('i18n:fr-template');
     $this->node->setProperty('i18n:fr-template', 'foobar')->shouldBeCalled();
     // 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->structureProperty->getContentTypeName()->willReturn('content_type');
     $this->contentTypeManager->get('content_type')->willReturn($this->contentType->reveal());
     $this->propertyFactory->createTranslatedProperty($this->structureProperty->reveal(), 'fr')->willReturn($this->legacyProperty->reveal());
     $this->structure->getProperty('prop1')->willReturn($this->propertyValue->reveal());
     $this->propertyValue->getValue()->willReturn('test');
     $this->contentType->remove($this->node->reveal(), $this->legacyProperty->reveal(), 'webspace', 'fr', null)->shouldBeCalled();
     $this->contentType->write($this->node->reveal(), $this->legacyProperty->reveal(), null, 'webspace', 'fr', null)->shouldBeCalled();
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }
Exemplo n.º 2
0
 /**
  * build categories where clauses.
  */
 private function buildCategoriesWhere($categories, $operator, $languageCode)
 {
     $structure = $this->structureManager->getStructure('excerpt');
     $sql2Where = [];
     if ($structure->hasProperty('categories')) {
         $property = new TranslatedProperty($structure->getProperty('categories'), $languageCode, $this->languageNamespace, 'excerpt');
         foreach ($categories as $category) {
             $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $category;
         }
         if (count($sql2Where) > 0) {
             return '(' . implode(' ' . strtoupper($operator) . ' ', $sql2Where) . ')';
         }
     }
     return '';
 }
Exemplo n.º 3
0
 /**
  * build tags where clauses.
  */
 private function buildTagsWhere($languageCode)
 {
     $structure = $this->structureManager->getStructure('excerpt');
     $sql2Where = [];
     if ($structure->hasProperty('tags')) {
         $tagOperator = $this->getConfig('tagOperator', 'OR');
         $property = new TranslatedProperty($structure->getProperty('tags'), $languageCode, $this->languageNamespace, 'excerpt');
         foreach ($this->getConfig('tags', []) as $tag) {
             $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $tag;
         }
         if (sizeof($sql2Where) > 0) {
             return '(' . implode(' ' . strtoupper($tagOperator) . ' ', $sql2Where) . ')';
         }
     }
     return '';
 }