Whenever details about Plugins or PluginViews are needed this service should be used. For some methods the ContentContext has to be specified. This is required in order for the ContentRepository to fetch nodes of the current workspace. The context can be retrieved from any node of the correct workspace & tree. If no node is available (e.g. for CLI requests) the ContentContextFactory can be used to create a context instance.
 /**
  * Returns the processed Configuration
  *
  * @param \Neos\ContentRepository\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' => 'Neos.Neos/Inspector/Editors/PluginViewsEditor')));
 }
Esempio n. 2
0
 /**
  * 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(Neos\Flow\Mvc\Routing\UriBuilder->uriFor())")
  * @param \Neos\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 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 Neos.Neos:Document]')->get(0);
     $result = $this->generateUriForNode($request, $joinPoint, $pageNode);
     return $result;
 }
 /**
  * Fetch all master plugins that are available in the current
  * workspace.
  *
  * @param string $workspaceName Name of the workspace to use for querying the node
  * @param array $dimensions Optional list of dimensions and their values which should be used for querying the specified node
  * @return string JSON encoded array of node path => label
  */
 public function masterPluginsAction($workspaceName = 'live', array $dimensions = array())
 {
     $this->response->setHeader('Content-Type', 'application/json');
     $contentContext = $this->createContentContext($workspaceName, $dimensions);
     $pluginNodes = $this->pluginService->getPluginNodesWithViewDefinitions($contentContext);
     $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 Neos.Neos:Document]')->get(0);
             if ($page === null) {
                 continue;
             }
             $translationHelper = new TranslationHelper();
             $masterPlugins[$pluginNode->getIdentifier()] = $translationHelper->translate('masterPlugins.nodeTypeOnPageLabel', null, ['nodeTypeName' => $translationHelper->translate($pluginNode->getNodeType()->getLabel()), 'pageLabel' => $page->getLabel()], 'Main', 'Neos.Neos');
         }
     }
     return json_encode((object) $masterPlugins);
 }