read() public method

Reads the value for given property from the content repository then sets the value of the Sulu property.
public read ( PHPCR\NodeInterface $node, Sulu\Component\Content\Compat\PropertyInterface $property, string $webspaceKey, string $languageCode, string $segmentKey ) : mixed
$node PHPCR\NodeInterface
$property Sulu\Component\Content\Compat\PropertyInterface
$webspaceKey string
$languageCode string
$segmentKey string
return mixed
Beispiel #1
0
 public function testPropertyRead()
 {
     $this->property->expects($this->exactly(2))->method('getName')->will($this->returnValue('i18n:de-hotels'));
     $this->property->expects($this->once())->method('setValue')->will($this->returnCallback(function ($snippets) {
         foreach ($snippets as $snippet) {
             $this->assertTrue(UUIDHelper::isUUID($snippet));
         }
     }));
     $pageNode = $this->session->getNode('/cmf/sulu_io/contents/hotels');
     $this->contentType->read($pageNode, $this->property, 'sulu_io', 'de', null);
 }
 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());
 }