Inheritance: extends Sulu\Component\Util\ArrayableInterface
Esempio n. 1
0
 private function getReferencedUuids(PropertyInterface $property)
 {
     $contentTypeName = $property->getContentTypeName();
     $contentType = $this->contentTypeManager->get($contentTypeName);
     $referencedUuids = $contentType->getReferencedUuids($property);
     return $referencedUuids;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $property->getValue();
     if ($value !== null && $value !== false && $value !== 'false' && $value !== '') {
         $node->setProperty($property->getName(), true);
     } else {
         $node->setProperty($property->getName(), false);
     }
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $property->getValue();
     if ($value !== null) {
         $node->setProperty($property->getName(), $this->removeValidation($this->removeIllegalCharacters($value)));
     } else {
         $this->remove($node, $property, $webspaceKey, $languageCode, $segmentKey);
     }
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = '';
     if ($node->hasProperty($property->getName())) {
         /** @var \DateTime $propertyValue */
         $propertyValue = $node->getPropertyValue($property->getName());
         $value = $propertyValue->format('Y-m-d');
     }
     $property->setValue($value);
     return $value;
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $this->defaultValue;
     if ($node->hasProperty($property->getName())) {
         $value = $node->getPropertyValue($property->getName());
     }
     // the RedirectType subscriber sets the internal link as a reference
     if ($value instanceof NodeInterface) {
         $value = $value->getIdentifier();
     }
     $property->setValue($value);
     return $value;
 }
Esempio n. 6
0
 public function testGetContentData()
 {
     $this->prepareSingleBlockProperty();
     $data = [['type' => 'type1', 'title' => 'Test-Title-1', 'article' => ['Test-Article-1-1', 'Test-Article-1-2'], 'sub-block' => ['type' => 'subType1', 'title' => 'Test-Title-Sub-1', 'article' => 'Test-Article-Sub-1']], ['type' => 'type2', 'name' => 'Test-Name-2']];
     $this->blockProperty->setValue($data);
     $result = $this->blockContentType->getContentData($this->blockProperty);
     $this->assertEquals($data, $result);
 }
Esempio n. 7
0
 public function testRemove()
 {
     $this->property->expects($this->any())->method('getName')->will($this->returnValue('i18n:de-hotels'));
     $pageNode = $this->session->getNode('/cmf/sulu_io/contents/hotels');
     $this->contentType->remove($pageNode, $this->property, 'sulu_io', 'de', null);
     $this->session->save();
     $this->assertFalse($pageNode->hasProperty('i18n:de-hotels'));
 }
 public function testGetContentDataWrongType()
 {
     $type = new ContactSelectionContentType($this->template, $this->contactManager->reveal(), $this->accountManager->reveal(), $this->serializer->reveal(), new CustomerIdConverter(), new IndexComparator());
     $this->property->getValue()->willReturn('blabla');
     $this->contactManager->getById(Argument::any(), Argument::any())->shouldNotBeCalled();
     $this->accountManager->getById(Argument::any(), Argument::any())->shouldNotBeCalled();
     $result = $type->getContentData($this->property->reveal());
     $this->assertCount(0, $result);
 }
Esempio n. 9
0
 private function doGetProperty($name, $contentTypeName, $locale)
 {
     $this->propertyMetadata->getType()->willReturn($contentTypeName);
     $this->structureMetadata->getProperty($name)->willReturn($this->propertyMetadata);
     $this->contentTypeManager->get($contentTypeName)->willReturn($this->contentType->reveal());
     if ($locale) {
         $this->propertyFactory->createTranslatedProperty($this->propertyMetadata->reveal(), $locale, Argument::type(StructureBridge::class))->willReturn($this->legacyProperty->reveal());
     } else {
         $this->propertyFactory->createProperty($this->propertyMetadata->reveal(), $locale)->willReturn($this->legacyProperty->reveal());
     }
     $this->contentType->read($this->node->reveal(), $this->legacyProperty->reveal(), null, null, null)->shouldBeCalledTimes(1);
     $property = $this->structure->getProperty($name);
     $this->assertInstanceOf(PropertyValue::class, $property);
     $this->assertEquals($name, $property->getName());
 }
Esempio n. 10
0
 /**
  * {@inheritdoc}
  */
 public function getReferencedUuids(PropertyInterface $property)
 {
     $data = $property->getValue();
     return $this->getUuids($data);
 }
Esempio n. 11
0
 /**
  * Return true if property is an array and needs an add button.
  *
  * @param $property PropertyInterface
  *
  * @return bool
  */
 public function needsAddButtonFunction(PropertyInterface $property)
 {
     return $property->getMaxOccurs() > $property->getMinOccurs();
 }
Esempio n. 12
0
 /**
  * Returns provider for given property.
  *
  * @param PropertyInterface $property
  *
  * @return DataProviderInterface
  */
 private function getProvider(PropertyInterface $property)
 {
     $params = $property->getParams();
     // default fallback to content
     $providerAlias = 'content';
     if (array_key_exists('provider', $params)) {
         $providerAlias = $params['provider']->getValue();
     }
     return $this->dataProviderPool->get($providerAlias);
 }
Esempio n. 13
0
 /**
  * {@inheritdoc.
  */
 public function setStructure($structure)
 {
     $this->property->setStructure($structure);
 }
 /**
  * Set data to given property.
  *
  * @param array $data
  * @param PropertyInterface $property
  */
 protected function setData($data, PropertyInterface $property)
 {
     $refs = isset($data) ? $data : [];
     $property->setValue($refs);
 }
Esempio n. 15
0
 /**
  * {@inheritDoc}
  */
 public function getContentData(PropertyInterface $property)
 {
     $data = $property->getValue();
     $container = new InternalLinksContainer(isset($data) ? $data : [], $this->contentQueryExecutor, $this->contentQueryBuilder, array_merge($this->getDefaultParams(), $property->getParams()), $this->logger, $property->getStructure()->getWebspaceKey(), $property->getStructure()->getLanguageCode());
     return $container->getData();
 }
Esempio n. 16
0
 /**
  * Returns property-value merged with defaults.
  *
  * @param PropertyInterface $property
  *
  * @return array
  */
 private function getValue(PropertyInterface $property)
 {
     $default = ['presentAs' => null, 'items' => []];
     if (!is_array($property->getValue())) {
         return $default;
     }
     return array_merge($default, $property->getValue());
 }
Esempio n. 17
0
 /**
  * {@inheritdoc}
  */
 public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey = null)
 {
     $this->strategy->deleteByPath($property->getValue(), $webspaceKey, $languageCode, $segmentKey);
     if ($node->hasProperty($property->getName())) {
         $node->getProperty($property->getName())->remove();
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getViewData(PropertyInterface $property)
 {
     return $property->getValue();
 }
Esempio n. 19
0
 /**
  * Returns prepared data from property
  * use callback to prepare data foreach property function($contentType, $property).
  *
  * @param PropertyInterface $property
  * @param callable          $dataCallback
  * @param bool              $returnType
  *
  * @return array
  */
 private function prepareData(PropertyInterface $property, callable $dataCallback, $returnType = true)
 {
     /** @var BlockPropertyInterface $blockProperty */
     $blockProperty = $property;
     while (!$blockProperty instanceof BlockPropertyInterface) {
         $blockProperty = $blockProperty->getProperty();
     }
     $data = [];
     for ($i = 0; $i < $blockProperty->getLength(); ++$i) {
         $blockPropertyType = $blockProperty->getProperties($i);
         if ($returnType) {
             $type = $blockPropertyType->getName();
             $data[$i] = ['type' => $type];
         }
         foreach ($blockPropertyType->getChildProperties() as $childProperty) {
             $contentType = $this->contentTypeManager->get($childProperty->getContentTypeName());
             $data[$i][$childProperty->getName()] = $dataCallback($contentType, $childProperty);
         }
     }
     if (!$property->getIsMultiple() && count($data) > 0) {
         $data = $data[0];
     }
     return $data;
 }
Esempio n. 20
0
 /**
  * Prepare document-property and import them.
  *
  * @param PropertyInterface $property
  * @param NodeInterface $node
  * @param string $value
  * @param string $webspaceKey
  * @param string $locale
  * @param string $format
  */
 protected function importProperty(PropertyInterface $property, NodeInterface $node, StructureInterface $structure, $value, $webspaceKey, $locale, $format)
 {
     $contentType = $property->getContentTypeName();
     if (!$this->contentImportManager->hasImport($contentType, $format)) {
         return;
     }
     $translateProperty = $this->legacyPropertyFactory->createTranslatedProperty($property, $locale, $structure);
     $this->contentImportManager->import($contentType, $node, $translateProperty, $value, null, $webspaceKey, $locale);
 }
Esempio n. 21
0
 /**
  * load data from container.
  *
  * @param SmartContentContainer $container
  * @param PropertyInterface     $property
  * @param PropertyParameter[]   $params
  *
  * @return array|\Sulu\Component\Content\Compat\StructureInterface[]
  */
 private function loadData(SmartContentContainer $container, PropertyInterface $property, $params)
 {
     if (isset($params['max_per_page'])) {
         // determine current page
         $container->setPage($this->getCurrentPage($params['page_parameter']->getValue()));
         $contentData = $this->getPagedContentData($container, $container->getPage(), intval($params['max_per_page']->getValue()), $property->getStructure()->getUuid());
     } else {
         // set default values
         $container->setPage(1);
         $container->setHasNextPage(false);
         $contentData = $this->getNotPagedContentData($container, $property->getStructure()->getUuid());
     }
     return $contentData;
 }
Esempio n. 22
0
 /**
  * add tags of properties.
  */
 protected function addPropertyTags(PropertyInterface $property)
 {
     foreach ($property->getTags() as $tag) {
         if (!array_key_exists($tag->getName(), $this->tags)) {
             $this->tags[$tag->getName()] = ['tag' => $tag, 'properties' => [$tag->getPriority() => $property], 'highest' => $property, 'lowest' => $property];
         } else {
             $this->tags[$tag->getName()]['properties'][$tag->getPriority()] = $property;
             // replace highest priority property
             $highestProperty = $this->tags[$tag->getName()]['highest'];
             if ($highestProperty->getTag($tag->getName())->getPriority() < $tag->getPriority()) {
                 $this->tags[$tag->getName()]['highest'] = $property;
             }
             // replace lowest priority property
             $lowestProperty = $this->tags[$tag->getName()]['lowest'];
             if ($lowestProperty->getTag($tag->getName())->getPriority() > $tag->getPriority()) {
                 $this->tags[$tag->getName()]['lowest'] = $property;
             }
         }
     }
 }
Esempio n. 23
0
 /**
  * {@inheritdoc}
  */
 public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     if ($node->hasProperty($property->getName())) {
         $property = $node->getProperty($property->getName());
         $property->remove();
     }
 }
Esempio n. 24
0
 /**
  * {@inheritdoc}
  */
 public function importData(NodeInterface $node, PropertyInterface $property, $value, $userId, $webspaceKey, $languageCode, $segmentKey = null)
 {
     $tagNames = [];
     $tagIds = json_decode($value);
     if (!empty($tagIds)) {
         $tagNames = $this->tagManager->resolveTagIds($tagIds);
     }
     $property->setValue($tagNames);
     $this->write($node, $property, $userId, $webspaceKey, $languageCode, $segmentKey);
 }
Esempio n. 25
0
 /**
  * @dataProvider provideGetReferencedUuids
  */
 public function testGetReferencedUuids($propertyValue, $expected)
 {
     $this->property->getValue()->willReturn($propertyValue);
     $uuids = $this->type->getReferencedUuids($this->property->reveal());
     $this->assertEquals($expected, $uuids);
 }
Esempio n. 26
0
 /**
  * {@inheritdoc}
  */
 public function importData(NodeInterface $node, PropertyInterface $property, $value, $userId, $webspaceKey, $languageCode, $segmentKey = null)
 {
     $property->setValue(json_decode($value, true));
     $this->write($node, $property, $userId, $webspaceKey, $languageCode, $segmentKey);
 }
Esempio n. 27
0
 public function __construct(PropertyInterface $property, ContentTypeInterface $contentType)
 {
     parent::__construct(sprintf('Property "%s" is unexcepted in content type "%s"', $property->getName(), get_class($contentType)));
     $this->property = $property;
     $this->contentType = $contentType;
 }