getPluginViewDefinitionsByPluginNodeType() public method

Get all configured PluginView definitions for a specific $pluginNodeType
public getPluginViewDefinitionsByPluginNodeType ( NodeType $pluginNodeType ) : array
$pluginNodeType Neos\ContentRepository\Domain\Model\NodeType node type name of the master plugin
return array
 /**
  * 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;
 }
 /**
  * Fetch the configured views for the given master plugin
  *
  * @param string $identifier Specifies the node to look up
  * @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
  */
 public function pluginViewsAction($identifier = null, $workspaceName = 'live', array $dimensions = array())
 {
     $this->response->setHeader('Content-Type', 'application/json');
     $contentContext = $this->createContentContext($workspaceName, $dimensions);
     /** @var $node NodeInterface */
     $node = $contentContext->getNodeByIdentifier($identifier);
     $views = array();
     if ($node !== null) {
         /** @var $pluginViewDefinition PluginViewDefinition */
         $pluginViewDefinitions = $this->pluginService->getPluginViewDefinitionsByPluginNodeType($node->getNodeType());
         foreach ($pluginViewDefinitions as $pluginViewDefinition) {
             $label = $pluginViewDefinition->getLabel();
             $views[$pluginViewDefinition->getName()] = array('label' => $label);
             $pluginViewNode = $this->pluginService->getPluginViewNodeByMasterPlugin($node, $pluginViewDefinition->getName());
             if ($pluginViewNode === null) {
                 continue;
             }
             $q = new FlowQuery(array($pluginViewNode));
             $page = $q->closest('[instanceof Neos.Neos:Document]')->get(0);
             $uri = $this->uriBuilder->reset()->uriFor('show', array('node' => $page), 'Frontend\\Node', 'Neos.Neos');
             $views[$pluginViewDefinition->getName()] = array('label' => $label, 'pageNode' => array('title' => $page->getLabel(), 'uri' => $uri));
         }
     }
     return json_encode((object) $views);
 }