Sulu\Bundle\ContactBundle\Content\Types\ContactSelectionContentType::read PHP Метод

read() публичный Метод

public read ( PHPCR\NodeInterface $node, Sulu\Component\Content\Compat\PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey )
$node PHPCR\NodeInterface
$property Sulu\Component\Content\Compat\PropertyInterface
    public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
    {
        $values = [];
        if ($node->hasProperty($property->getName())) {
            $values = $node->getPropertyValue($property->getName());
        }
        $refs = isset($values) ? $values : [];
        $property->setValue($refs);
    }

Usage Example

 public function testReadPropertyNotExists()
 {
     $type = new ContactSelectionContentType($this->template, $this->contactManager->reveal(), $this->accountManager->reveal(), $this->serializer->reveal(), new CustomerIdConverter(), new IndexComparator());
     $this->property->getName()->willReturn('test');
     $this->node->hasProperty('test')->willReturn(false);
     $this->node->getPropertyValue(Argument::any(), Argument::any())->shouldNotBeCalled();
     $this->property->setValue([])->shouldBeCalled();
     $type->read($this->node->reveal(), $this->property->reveal(), $this->webspaceKey, $this->locale, $this->segmentKey);
 }