Exemple #1
0
 public function fromProperty(PropertyMetadata $property, $locale = null)
 {
     if (true === $property->isLocalized()) {
         return $this->localizedContentName($property->getName(), $locale);
     }
     return $this->contentname($property->getName());
 }
 /**
  * It should create standard properties from "new" properties.
  */
 public function testCreateProperty()
 {
     $name = 'foo';
     $title = ['de' => 'Tite'];
     $description = ['de' => 'Description'];
     $placeholder = ['de' => 'Placehodler'];
     $type = 'type';
     $required = true;
     $localized = true;
     $maxOccurs = 1;
     $minOccurs = 1;
     $parameters = [['name' => 'prop', 'type' => 'type', 'value' => 'value', 'meta' => []], ['name' => 'propfoo', 'type' => 'type', 'value' => 'value', 'meta' => []]];
     $colSpan = 6;
     $this->property1->getType()->willReturn($type);
     $this->property1->getName()->willReturn($name);
     $this->property1->isRequired()->willReturn($required);
     $this->property1->isLocalized()->willReturn($required);
     $this->property1->getMaxOccurs()->willReturn($maxOccurs);
     $this->property1->getMinOccurs()->willReturn($minOccurs);
     $this->property1->getColSpan()->willReturn($colSpan);
     $this->property1->getParameters()->willReturn($parameters);
     $this->property1->title = $title;
     $this->property1->description = $description;
     $this->property1->placeholder = $placeholder;
     $legacyProperty = $this->factory->createProperty($this->property1->reveal());
     $this->assertInstanceOf(LegacyPropertyInterface::class, $legacyProperty);
     $this->assertEquals($legacyProperty->getContentTypeName(), $type);
     $this->assertEquals($legacyProperty->getName(), $name);
     $this->assertEquals($legacyProperty->getMandatory(), $required);
     $this->assertEquals($legacyProperty->getMultilingual(), $localized);
     $this->assertEquals($legacyProperty->getMaxOccurs(), $maxOccurs);
     $this->assertEquals($legacyProperty->getMinOccurs(), $minOccurs);
     $this->assertEquals($legacyProperty->getColspan(), $colSpan);
     $this->assertContainsOnlyInstancesOf(PropertyParameter::class, $legacyProperty->getParams());
     $this->assertArrayHasKey('prop', $legacyProperty->getParams());
     $this->assertArrayHasKey('propfoo', $legacyProperty->getParams());
     $this->assertEquals($title['de'], $legacyProperty->getTitle('de'));
     $this->assertEquals($description['de'], $legacyProperty->getInfoText('de'));
     $this->assertEquals($placeholder['de'], $legacyProperty->getPlaceholder('de'));
     return $this->property1;
 }
 /**
  * Sets the ResourceSegment to the given property of the given document.
  *
  * @param ResourceSegmentBehavior $document
  * @param PropertyMetadata $property
  */
 private function persistDocument(ResourceSegmentBehavior $document, PropertyMetadata $property)
 {
     $document->getStructure()->getProperty($property->getName())->setValue($document->getResourceSegment());
 }
 private function getContentField(PropertyMetadata $property)
 {
     $field = $this->factory->createMetadataExpression(sprintf('object.getStructure().%s.getValue()', $property->getName()));
     return $field;
 }
 /**
  * Upgrades the given property to the new date representation.
  *
  * @param PropertyMetadata $property
  * @param NodeInterface $node
  * @param bool $up
  */
 private function upgradeProperty(PropertyMetadata $property, NodeInterface $node, $locale, $up)
 {
     $name = sprintf('i18n:%s-%s', $locale, $property->getName());
     if (!$node->hasProperty($name)) {
         return;
     }
     $value = $node->getPropertyValue($name);
     if ($up) {
         $value = $this->upgradeDate($value);
     } else {
         $value = $this->downgradeDate($value);
     }
     $node->setProperty($name, $value);
 }
Exemple #6
0
 /**
  * Creates and returns a property-array.
  *
  * @param PropertyMetadata $property
  * @param PropertyValue $propertyValue
  * @param string $format
  *
  * @return array
  */
 protected function getPropertyData(PropertyMetadata $property, $propertyValue, $format)
 {
     return $this->createProperty($property->getName(), $this->contentExportManager->export($property->getType(), $propertyValue), $this->contentExportManager->getOptions($property->getType(), $format), $property->getType());
 }