Neos\Neos\Service\ContentElementEditableService::wrapContentProperty PHP Метод

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

Wrap the $content identified by $node with the needed markup for the backend.
public wrapContentProperty ( Neos\ContentRepository\Domain\Model\NodeInterface $node, string $property, string $content ) : string
$node Neos\ContentRepository\Domain\Model\NodeInterface
$property string
$content string
Результат string
    public function wrapContentProperty(NodeInterface $node, $property, $content)
    {
        /** @var $contentContext ContentContext */
        $contentContext = $node->getContext();
        if ($contentContext->getWorkspaceName() === 'live' || !$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
            return $content;
        }
        if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) {
            return $content;
        }
        $attributes = array();
        $attributes['class'] = 'neos-inline-editable';
        $attributes['property'] = 'typo3:' . $property;
        $attributes['data-neos-node-type'] = $node->getNodeType()->getName();
        return $this->htmlAugmenter->addAttributes($content, $attributes, 'span');
    }

Usage Example

 /**
  * @test
  */
 public function wrapContentPropertyDoesNotAddEditingMetaDataIfEditNodePrivilegeIsNotGranted()
 {
     $this->mockContentContext->expects($this->atLeastOnce())->method('getWorkspaceName')->will($this->returnValue('not-live'));
     $this->mockPrivilegeManager->expects($this->atLeastOnce())->method('isPrivilegeTargetGranted')->with('Neos.Neos:Backend.GeneralAccess')->will($this->returnValue(true));
     $this->mockNodeAuthorizationService->expects($this->atLeastOnce())->method('isGrantedToEditNode')->will($this->returnValue(false));
     $this->mockHtmlAugmenter->expects($this->never())->method('addAttributes');
     $this->contentElementEditableService->wrapContentProperty($this->mockNode, 'someProperty', '<div>someRenderedPropertyValue</div>');
 }
All Usage Examples Of Neos\Neos\Service\ContentElementEditableService::wrapContentProperty
ContentElementEditableService