/** * {@inheritdoc} */ public function readForPreview($data, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey) { if ($data !== null && $data !== false && $data !== 'false' && $data !== '') { $property->setValue(true); } else { $property->setValue(false); } }
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); }
public function testWriteNull() { $type = new ContactSelectionContentType($this->template, $this->contactManager->reveal(), $this->accountManager->reveal(), $this->serializer->reveal(), new CustomerIdConverter(), new IndexComparator()); $this->property->getName()->willReturn('test'); $this->property->getValue()->willReturn(null); $this->property->setValue(Argument::any())->shouldNotBeCalled(); $this->node->setProperty('test', [])->shouldBeCalled(); $type->write($this->node->reveal(), $this->property->reveal(), $this->userId, $this->webspaceKey, $this->locale, $this->segmentKey); }
/** * {@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; }
/** * {@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; }
/** * {@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); }
/** * {@inheritdoc} */ public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey) { $value = $node->getPropertyValueWithDefault($property->getName(), $this->defaultValue); $property->setValue($this->validate($value, $languageCode)); return $value; }
/** * Set data to given property. * * @param array $data * @param PropertyInterface $property */ protected function setData($data, PropertyInterface $property) { $refs = isset($data) ? $data : []; $property->setValue($refs); }
/** * {@inheritdoc} */ public function readForPreview($data, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey) { if ($data instanceof ArrayableInterface) { $data = $data->toArray(); } $property->setValue($data); }
/** * sets the value from property. * * @param $value mixed */ public function setValue($value) { $this->property->setValue($value); }
/** * Sets the given array as values on the property. * * @param array $data * @param PropertyInterface $property */ protected function setData($data, PropertyInterface $property) { $property->setValue($data); }
/** * {@inheritdoc} */ public function readForPreview($data, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey = null) { $property->setValue($data); }
/** * set data to property. * * @param string[] $data ids of images * @param PropertyInterface $property * @param $languageCode */ private function setData($data, PropertyInterface $property, $languageCode) { $property->setValue($data); }
/** * {@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); }
/** * @param $data * @param PropertyInterface $property * @param string $webspaceKey * @param string $languageCode * @param string $segmentKey * @param bool $preview */ protected function setData($data, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey, $preview = false) { $property->setValue($data); }
/** * {@inheritdoc} */ public function readForPreview($data, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey) { if ($property->getIsBlock()) { /** @var BlockPropertyInterface $blockProperty */ $blockProperty = $property; while (!$blockProperty instanceof BlockPropertyInterface) { $blockProperty = $blockProperty->getProperty(); } $blockProperty->clearProperties(); $len = count($data); for ($i = 0; $i < $len; ++$i) { $blockPropertyType = $blockProperty->initProperties($i, $data[$i]['type']); /** @var PropertyInterface $subProperty */ foreach ($blockPropertyType->getChildProperties() as $subProperty) { if (isset($data[$i][$subProperty->getName()])) { $contentType = $this->contentTypeManager->get($subProperty->getContentTypeName()); $contentType->readForPreview($data[$i][$subProperty->getName()], $subProperty, $webspaceKey, $languageCode, $segmentKey); } } } $property->setValue($data); } else { throw new UnexpectedPropertyType($property, $this); } }