/** * Returns the processed Configuration * * @param \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType (uninitialized) The node type to process * @param array $configuration input configuration * @param array $options The processor options * @return void */ public function process(NodeType $nodeType, array &$configuration, array $options) { $pluginViewDefinitions = $this->pluginService->getPluginViewDefinitionsByPluginNodeType($nodeType); if ($pluginViewDefinitions === array()) { return; } $configuration['ui']['inspector']['groups']['pluginViews'] = array('position' => '9999', 'label' => 'Plugin Views'); $configuration['properties']['views'] = array('type' => 'string', 'ui' => array('inspector' => array('group' => 'pluginViews', 'position' => '20', 'editor' => 'TYPO3.Neos/Inspector/Editors/PluginViewsEditor'))); }
/** * Build the proper pluginRequest to render the PluginView * of some configured Master Plugin * * @return ActionRequest */ protected function buildPluginRequest() { /** @var $parentRequest ActionRequest */ $parentRequest = $this->tsRuntime->getControllerContext()->getRequest(); $pluginRequest = new ActionRequest($parentRequest); if (!$this->pluginViewNode instanceof NodeInterface) { $pluginRequest->setArgumentNamespace('--' . $this->getPluginNamespace()); $this->passArgumentsToPluginRequest($pluginRequest); $pluginRequest->setControllerPackageKey($this->getPackage()); $pluginRequest->setControllerSubpackageKey($this->getSubpackage()); $pluginRequest->setControllerName($this->getController()); $pluginRequest->setControllerActionName($this->getAction()); return $pluginRequest; } $pluginNodeIdentifier = $this->pluginViewNode->getProperty('plugin'); if (strlen($pluginNodeIdentifier) === 0) { return $pluginRequest; } // Set the node to render this to the master plugin node $this->node = $this->pluginViewNode->getContext()->getNodeByIdentifier($pluginNodeIdentifier); if ($this->node === null) { return $pluginRequest; } $pluginRequest->setArgument('__node', $this->node); $pluginRequest->setArgumentNamespace('--' . $this->getPluginNamespace()); $this->passArgumentsToPluginRequest($pluginRequest); if ($pluginRequest->getControllerObjectName() !== '') { return $pluginRequest; } $controllerObjectPairs = array(); $pluginViewName = $this->pluginViewNode->getProperty('view'); foreach ($this->pluginService->getPluginViewDefinitionsByPluginNodeType($this->node->getNodeType()) as $pluginViewDefinition) { /** @var PluginViewDefinition $pluginViewDefinition */ if ($pluginViewDefinition->getName() !== $pluginViewName) { continue; } $controllerObjectPairs = $pluginViewDefinition->getControllerActionPairs(); break; } if ($controllerObjectPairs === array()) { return $pluginRequest; } $defaultControllerObjectName = key($controllerObjectPairs); $defaultActionName = current($controllerObjectPairs[$defaultControllerObjectName]); $pluginRequest->setControllerObjectName($defaultControllerObjectName); $pluginRequest->setControllerActionName($defaultActionName); return $pluginRequest; }
/** * @Flow\Around("method(TYPO3\Flow\Mvc\Routing\UriBuilder->uriFor())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return string The result of the target method if it has not been intercepted */ public function rewritePluginViewUris(JoinPointInterface $joinPoint) { /** @var \TYPO3\Flow\Mvc\ActionRequest $request */ $request = $joinPoint->getProxy()->getRequest(); $arguments = $joinPoint->getMethodArguments(); $currentNode = $request->getInternalArgument('__node'); if (!$request->getMainRequest()->hasArgument('node') || !$currentNode instanceof Node) { return $joinPoint->getAdviceChain()->proceed($joinPoint); } $currentNode = $request->getInternalArgument('__node'); $controllerObjectName = $this->getControllerObjectName($request, $arguments); $actionName = $arguments['actionName'] !== null ? $arguments['actionName'] : $request->getControllerActionName(); $targetNode = $this->pluginService->getPluginNodeByAction($currentNode, $controllerObjectName, $actionName); // TODO override namespace $q = new FlowQuery(array($targetNode)); $pageNode = $q->closest('[instanceof TYPO3.Neos:Document]')->get(0); $result = $this->generateUriForNode($request, $joinPoint, $pageNode); return $result; }
/** * Fetch all master plugins that are available in the current * workspace. * * @param NodeInterface $node * @return string JSON encoded array of node path => label */ public function masterPluginsAction(NodeInterface $node) { $this->response->setHeader('Content-Type', 'application/json'); $pluginNodes = $this->pluginService->getPluginNodesWithViewDefinitions($node->getContext()); $masterPlugins = array(); if (is_array($pluginNodes)) { /** @var $pluginNode NodeInterface */ foreach ($pluginNodes as $pluginNode) { if ($pluginNode->isRemoved()) { continue; } $q = new FlowQuery(array($pluginNode)); $page = $q->closest('[instanceof TYPO3.Neos:Document]')->get(0); if ($page === NULL) { continue; } $masterPlugins[$pluginNode->getPath()] = sprintf('"%s" on page "%s"', $pluginNode->getNodeType()->getLabel(), $page->getLabel()); } } return json_encode((object) $masterPlugins); }
/** * Fetch all master plugins that are available in the current * workspace. * * @param NodeInterface $node * @return string JSON encoded array of node path => label */ public function masterPluginsAction(NodeInterface $node) { $this->response->setHeader('Content-Type', 'application/json'); $pluginNodes = $this->pluginService->getPluginNodesWithViewDefinitions($node->getContext()); $masterPlugins = array(); if (is_array($pluginNodes)) { /** @var $pluginNode NodeInterface */ foreach ($pluginNodes as $pluginNode) { if ($pluginNode->isRemoved()) { continue; } $q = new FlowQuery(array($pluginNode)); $page = $q->closest('[instanceof TYPO3.Neos:Document]')->get(0); if ($page === null) { continue; } $translationHelper = new TranslationHelper(); $masterPlugins[$pluginNode->getPath()] = $translationHelper->translate('masterPlugins.nodeTypeOnPageLabel', null, ['nodeTypeName' => $translationHelper->translate($pluginNode->getNodeType()->getLabel()), 'pageLabel' => $page->getLabel()], 'Main', 'TYPO3.Neos'); } } return json_encode((object) $masterPlugins); }