Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * 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;
     });
 }
 /**
  * Convert array to change interface
  *
  * @param array $changeData
  * @return ChangeInterface
  */
 protected function convertChangeData($changeData)
 {
     $type = $changeData['type'];
     if (!isset($this->typeMap[$type])) {
         return new \TYPO3\Flow\Error\Error(sprintf('Could not convert change type %s, it is unknown to the system', $type));
     }
     $changeClass = $this->typeMap[$type];
     $changeClassInstance = $this->objectManager->get($changeClass);
     $subjectContextPath = $changeData['subject'];
     $subject = $this->nodeService->getNodeFromContextPath($subjectContextPath);
     if ($subject instanceof \TYPO3\Flow\Error\Error) {
         return $subject;
     }
     $changeClassInstance->setSubject($subject);
     if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) {
         $referenceContextPath = $changeData['reference'];
         $reference = $this->nodeService->getNodeFromContextPath($referenceContextPath);
         if ($reference instanceof \TYPO3\Flow\Error\Error) {
             return $reference;
         }
         $changeClassInstance->setReference($reference);
     }
     if (isset($changeData['payload'])) {
         foreach ($changeData['payload'] as $key => $value) {
             if (!in_array($key, $this->disallowedPayloadProperties)) {
                 ObjectAccess::setProperty($changeClassInstance, $key, $value);
             }
         }
     }
     return $changeClassInstance;
 }
 /**
  * Build and execute a flow query chain
  *
  * @param array $chain
  * @return void
  */
 public function flowQueryAction(array $chain)
 {
     $createContext = array_shift($chain);
     $finisher = array_pop($chain);
     $flowQuery = new FlowQuery(array_map(function ($envelope) {
         return $this->nodeService->getNodeFromContextPath($envelope['$node']);
     }, $createContext['payload']));
     foreach ($chain as $operation) {
         $flowQuery = call_user_func_array([$flowQuery, strtolower($operation['type'])], $operation['payload']);
     }
     if ('GET' === $finisher['type']) {
         $result = $flowQuery->get();
     }
     $nodeInfoHelper = new NodeInfoHelper();
     return json_encode($nodeInfoHelper->renderNodes($result, $this->getControllerContext()));
 }
 /**
  * Convert array to change interface
  *
  * @param array $changeData
  * @return ChangeInterface
  */
 protected function convertChangeData($changeData)
 {
     $type = $changeData['type'];
     if (!isset($this->typeMap[$type])) {
         return new \TYPO3\Flow\Error\Error(sprintf('Could not convert change type %s, it is unknown to the system', $type));
     }
     $changeClass = $this->typeMap[$type];
     $changeClassInstance = $this->objectManager->get($changeClass);
     $changeClassInstance->injectPersistenceManager($this->persistenceManager);
     $subjectContextPath = $changeData['subject'];
     $subject = $this->nodeService->getNodeFromContextPath($subjectContextPath);
     if ($subject instanceof \TYPO3\Flow\Error\Error) {
         return $subject;
     }
     $changeClassInstance->setSubject($subject);
     if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) {
         $referenceContextPath = $changeData['reference'];
         $reference = $this->nodeService->getNodeFromContextPath($referenceContextPath);
         if ($reference instanceof \TYPO3\Flow\Error\Error) {
             return $reference;
         }
         $changeClassInstance->setReference($reference);
     }
     if (isset($changeData['payload'])) {
         foreach ($changeData['payload'] as $propertyName => $value) {
             if (!in_array($propertyName, $this->disallowedPayloadProperties)) {
                 $methodParameters = $this->reflectionService->getMethodParameters($changeClass, ObjectAccess::buildSetterMethodName($propertyName));
                 $methodParameter = current($methodParameters);
                 $targetType = $methodParameter['type'];
                 $value = $this->propertyMapper->convert($value, $targetType);
                 ObjectAccess::setProperty($changeClassInstance, $propertyName, $value);
             }
         }
     }
     return $changeClassInstance;
 }
Example #6
0
 /**
  * Set the active node
  *
  * @param string $activeContextPath
  * @return void
  */
 public function setActive($activeContextPath)
 {
     $this->active = $this->nodeService->getNodeFromContextPath($activeContextPath);
 }
Example #7
0
 /**
  * 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);
     }
 }