Helper method to retrieve the closest document for a node
public getClosestDocument ( TYPO3\TYPO3CR\Domain\Model\NodeInterface $node ) : TYPO3\TYPO3CR\Domain\Model\NodeInterface | ||
$node | TYPO3\TYPO3CR\Domain\Model\NodeInterface | |
return | TYPO3\TYPO3CR\Domain\Model\NodeInterface |
/** * Get all publishable node context paths for a workspace * * @param Workspace $workspace * @return array */ public function getPublishableNodeInfo(Workspace $workspace) { $publishableNodes = $this->publishingService->getUnpublishedNodes($workspace); $publishableNodes = array_map(function ($node) { if ($documentNode = $this->nodeService->getClosestDocument($node)) { return ['contextPath' => $node->getContextPath(), 'documentContextPath' => $documentNode->getContextPath()]; } }, $publishableNodes); return array_filter($publishableNodes, function ($item) { return (bool) $item; }); }
/** * Helper method to inform the client, that new workspace information is available * * @return void */ protected function updateWorkspaceInfo() { $nodeService = new NodeService(); $updateWorkspaceInfo = new UpdateWorkspaceInfo(); $updateWorkspaceInfo->setDocument($nodeService->getClosestDocument($this->getSubject())); $this->feedbackCollection->add($updateWorkspaceInfo); }
/** * Discard nodes * * @param array $nodeContextPaths * @return void */ public function discardAction(array $nodeContextPaths) { try { foreach ($nodeContextPaths as $contextPath) { $node = $this->nodeService->getNodeFromContextPath($contextPath); $this->publishingService->discardNode($node); $reloadDocument = new ReloadDocument(); $reloadDocument->setDocument($this->nodeService->getClosestDocument($node)); $this->feedbackCollection->add($reloadDocument); } $success = new Success(); $success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths))); $this->updateWorkspaceInfo($nodeContextPaths[0]); $this->feedbackCollection->add($success); $this->persistenceManager->persistAll(); } catch (\Exception $e) { $error = new Error(); $error->setMessage($e->getMessage()); $this->feedbackCollection->add($error); } $this->view->assign('value', $this->feedbackCollection); }
/** * Inform the client that a node has been created, the client decides if and which tree should react to this change. * * @return void */ protected function addDocumentNodeCreatedFeedback() { $nodeService = new NodeService(); $node = $nodeService->getClosestDocument($this->getSubject()); if ($nodeService->isDocument($node)) { $documentNodeCreated = new DocumentNodeCreated(); $documentNodeCreated->setDocumentNode($node); $this->feedbackCollection->add($documentNodeCreated); } }