/**
  * @test
  */
 public function wrapContentPropertyDoesNotAddEditingMetaDataIfEditNodePrivilegeIsNotGranted()
 {
     $this->mockContentContext->expects($this->atLeastOnce())->method('getWorkspaceName')->will($this->returnValue('not-live'));
     $this->mockPrivilegeManager->expects($this->atLeastOnce())->method('isPrivilegeTargetGranted')->with('TYPO3.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>');
 }
 /**
  * @test
  */
 public function renderCallsContentElementEditableServiceForAugmentation()
 {
     $this->templateVariables = array('someProperty' => 'somePropertyValue');
     $this->tagBuilder->expects($this->once())->method('render')->with()->willReturn('<div>somePropertyValue</div>');
     $this->mockContentElementEditableService->expects($this->once())->method('wrapContentProperty')->with($this->mockNode, 'someProperty', '<div>somePropertyValue</div>');
     $this->injectDependenciesIntoViewHelper($this->editableViewHelper);
     $this->injectTypoScriptObject();
     $this->editableViewHelper->render('someProperty');
 }
 /**
  * Evaluate this TypoScript object and return the result
  *
  * @return mixed
  */
 public function evaluate()
 {
     $content = $this->getValue();
     /** @var $node NodeInterface */
     $node = $this->tsValue('node');
     if (!$node instanceof NodeInterface) {
         return $content;
     }
     /** @var $property string */
     $property = $this->tsValue('property');
     /** @var $contentContext ContentContext */
     $contentContext = $node->getContext();
     if ($contentContext->getWorkspaceName() === 'live') {
         return $content;
     }
     if (!$this->privilegeManager->isPrivilegeTargetGranted('TYPO3.Neos:Backend.GeneralAccess')) {
         return $content;
     }
     if ($node->isRemoved()) {
         $content = '';
     }
     return $this->contentElementEditableService->wrapContentProperty($node, $property, $content);
 }
 /**
  * In live workspace this just renders a tag; for logged in users with access to the Backend this also adds required
  * attributes for the editing.
  *
  * @param string $property Name of the property to render. Note: If this tag has child nodes, they overrule this argument!
  * @param string $tag The name of the tag that should be wrapped around the property. By default this is a <div>
  * @param NodeInterface $node The node of the content element. Optional, will be resolved from the TypoScript context by default.
  * @return string The rendered property with a wrapping tag. In the user workspace this adds some required attributes for the RTE to work
  * @throws ViewHelperException
  */
 public function render($property, $tag = 'div', NodeInterface $node = null)
 {
     $this->tag->setTagName($tag);
     $this->tag->forceClosingTag(true);
     $content = $this->renderChildren();
     if ($node === null) {
         $node = $this->getNodeFromTypoScriptContext();
     }
     if ($node === null) {
         throw new ViewHelperException('A node is required, but one was not supplied and could not be found in the TypoScript context.', 1408521638);
     }
     if ($content === null) {
         if (!$this->templateVariableContainer->exists($property)) {
             throw new ViewHelperException(sprintf('The property "%1$s" was not set as a template variable. If you use this ViewHelper in a partial, make sure to pass the node property "%1$s" as an argument.', $property), 1384507046);
         }
         $content = $this->templateVariableContainer->get($property);
     }
     $this->tag->setContent($content);
     return $this->contentElementEditableService->wrapContentProperty($node, $property, $this->tag->render());
 }