/** * @test */ public function getUserWorkspaceReturnsTheUsersWorkspaceIfAUserIsLoggedIn() { $mockUserWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock(); $mockAccount = $this->getMockBuilder('TYPO3\\Flow\\Security\\Account')->disableOriginalConstructor()->getMock(); $mockAccount->expects($this->atLeastOnce())->method('getAccountIdentifier')->will($this->returnValue('The UserName')); $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAccount')->will($this->returnValue($mockAccount)); $this->mockWorkspaceRepository->expects($this->atLeastOnce())->method('findOneByName')->with('user-TheUserName')->will($this->returnValue($mockUserWorkspace)); $this->assertSame($mockUserWorkspace, $this->userService->getUserWorkspace()); }
/** * Returns the node this even refers to, if it can be resolved. * * It might happen that, if this event refers to a node contained in a site which is not available anymore, * Doctrine's proxy class of the Site domain model will fail with an EntityNotFoundException. We catch this * case and return NULL. * * @return NodeInterface */ public function getNode() { try { $context = $this->contextFactory->create(array('workspaceName' => $this->userService->getUserWorkspace()->getName(), 'dimensions' => $this->dimension, 'currentSite' => $this->getCurrentSite(), 'invisibleContentShown' => true)); return $context->getNodeByIdentifier($this->nodeIdentifier); } catch (EntityNotFoundException $e) { return null; } }
/** * Display a list of unpublished content * * @param Workspace $workspace * @return void * @todo Pagination * @todo Tree filtering + level limit * @todo Search field * @todo Difference mechanism */ public function indexAction(Workspace $workspace = NULL) { if ($workspace === NULL) { $workspace = $this->userService->getUserWorkspace(); } $sites = array(); foreach ($this->publishingService->getUnpublishedNodes($workspace) as $node) { $pathParts = explode('/', $node->getPath()); if (count($pathParts) > 2) { $siteNodeName = $pathParts[2]; $q = new FlowQuery(array($node)); $document = $q->closest('[instanceof TYPO3.Neos:Document]')->get(0); // FIXME: $document will be NULL if we have a broken rootline for this node. This actually should never happen, but currently can in some scenarios. if ($document !== NULL) { $documentPath = implode('/', array_slice(explode('/', $document->getPath()), 3)); $relativePath = str_replace(sprintf('/sites/%s/%s', $siteNodeName, $documentPath), '', $node->getPath()); if (!isset($sites[$siteNodeName]['siteNode'])) { $sites[$siteNodeName]['siteNode'] = $this->siteRepository->findOneByNodeName($siteNodeName); } $sites[$siteNodeName]['documents'][$documentPath]['documentNode'] = $document; $change = array('node' => $node); if ($node->getNodeType()->isOfType('TYPO3.Neos:Node')) { $change['configuration'] = $node->getNodeType()->getFullConfiguration(); } $sites[$siteNodeName]['documents'][$documentPath]['changes'][$relativePath] = $change; } } } $liveContext = $this->contextFactory->create(array('workspaceName' => 'live')); ksort($sites); foreach ($sites as $siteKey => $site) { foreach ($site['documents'] as $documentKey => $document) { foreach ($document['changes'] as $changeKey => $change) { $liveNode = $liveContext->getNodeByIdentifier($change['node']->getIdentifier()); $sites[$siteKey]['documents'][$documentKey]['changes'][$changeKey]['isNew'] = is_null($liveNode); $sites[$siteKey]['documents'][$documentKey]['changes'][$changeKey]['isMoved'] = $liveNode && $change['node']->getPath() !== $liveNode->getPath(); } } ksort($sites[$siteKey]['documents']); } $workspaces = array(); foreach ($this->workspaceRepository->findAll() as $workspaceInstance) { array_push($workspaces, array('workspaceNode' => $workspaceInstance, 'unpublishedNodesCount' => $this->publishingService->getUnpublishedNodesCount($workspaceInstance))); } $this->view->assignMultiple(array('workspace' => $workspace, 'workspaces' => $workspaces, 'sites' => $sites)); }