Inheritance: extends Neos\ContentRepository\Domain\Service\Context
 /**
  * @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>');
 }
コード例 #2
0
 /**
  * @test
  */
 public function viewHelperRendersUriViaStringPointingToSubNodes()
 {
     $this->tsRuntime->pushContext('documentNode', $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission'));
     $this->assertSame('<a href="/en/home/about-us/history.html">History</a>', $this->viewHelper->render('../history'));
     $this->tsRuntime->popContext();
     $this->assertSame('<a href="/en/home/about-us/our-mission.html">Our mission</a>', $this->viewHelper->render('about-us/mission'));
     $this->assertSame('<a href="/en/home/about-us/our-mission.html">Our mission</a>', $this->viewHelper->render('./about-us/mission'));
 }
コード例 #3
0
 /**
  * @test
  */
 public function viewHelperRendersUriViaStringPointingToSubNodes()
 {
     $this->tsRuntime->pushContext('documentNode', $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission'));
     $this->assertOutputLinkValid('en/home/about-us/history.html', $this->viewHelper->render('../history'));
     $this->tsRuntime->popContext();
     $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->viewHelper->render('about-us/mission'));
     $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->viewHelper->render('./about-us/mission'));
 }
コード例 #4
0
 /**
  * Sets up a view with context for testing
  *
  * @return void
  */
 public function setUpMockView()
 {
     $this->mockContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock();
     $mockNode = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
     $this->mockContextualizedNode = $this->getMockBuilder(Node::class)->setMethods(array('getContext'))->setConstructorArgs(array($mockNode, $this->mockContext))->getMock();
     $mockSiteNode = $this->createMock(NodeInterface::class);
     $this->mockContext->expects($this->any())->method('getCurrentSiteNode')->will($this->returnValue($mockSiteNode));
     $this->mockContext->expects($this->any())->method('getDimensions')->will($this->returnValue(array()));
     $this->mockContextualizedNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
     $mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
     $this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $mockTypoScriptService = $this->createMock(TypoScriptService::class);
     $mockTypoScriptService->expects($this->any())->method('createRuntime')->will($this->returnValue($this->mockRuntime));
     $this->mockView = $this->getAccessibleMock(TypoScriptView::class, array('getClosestDocumentNode'));
     $this->mockView->expects($this->any())->method('getClosestDocumentNode')->will($this->returnValue($this->mockContextualizedNode));
     $this->inject($this->mockView, 'controllerContext', $mockControllerContext);
     $this->inject($this->mockView, 'securityContext', $this->mockSecurityContext);
     $this->inject($this->mockView, 'typoScriptService', $mockTypoScriptService);
     $this->mockView->_set('variables', array('value' => $this->mockContextualizedNode));
 }
コード例 #5
0
 /**
  * Adopt (translate) the given node and parents that are not yet visible to the given context
  *
  * @param NodeInterface $node
  * @param ContentContext $contentContext
  * @param boolean $copyContent TRUE if the content from the nodes that are translated should be copied
  * @return void
  */
 protected function adoptNodeAndParents(NodeInterface $node, ContentContext $contentContext, $copyContent)
 {
     $contentContext->adoptNode($node, $copyContent);
     $parentNode = $node;
     while ($parentNode = $parentNode->getParent()) {
         $visibleInContext = $contentContext->getNodeByIdentifier($parentNode->getIdentifier()) !== null;
         if ($parentNode->getPath() !== '/' && $parentNode->getPath() !== SiteService::SITES_ROOT_PATH && !$visibleInContext) {
             $contentContext->adoptNode($parentNode, $copyContent);
         }
     }
 }
コード例 #6
0
 /**
  * Collects all hostnames from the Domain entries attached to the current site.
  *
  * @param ContentContext $contentContext
  * @return array
  */
 protected function getHostnames(ContentContext $contentContext)
 {
     $site = $contentContext->getCurrentSite();
     $domains = [];
     if ($site !== null) {
         foreach ($site->getActiveDomains() as $domain) {
             /** @var Domain $domain */
             $domains[] = $domain->getHostname();
         }
     }
     return $domains;
 }
コード例 #7
0
 /**
  * Find all nodes of a specific node type
  *
  * @param array $nodeTypes
  * @param ContentContext $context current content context, see class doc comment for details
  * @return array<NodeInterface> all nodes of type $nodeType in the current $context
  */
 protected function getNodes(array $nodeTypes, ContentContext $context)
 {
     $nodes = [];
     $siteNode = $context->getCurrentSiteNode();
     foreach ($this->nodeDataRepository->findByParentAndNodeTypeRecursively($siteNode->getPath(), implode(',', $nodeTypes), $context->getWorkspace()) as $nodeData) {
         $nodes[] = $this->nodeFactory->createFromNodeData($nodeData, $context);
     }
     return $nodes;
 }