Neos\Neos\Service\PluginService::getPluginViewNodeByMasterPlugin PHP Method

getPluginViewNodeByMasterPlugin() public method

returns a specific view node of an master plugin or NULL if it does not exist
public getPluginViewNodeByMasterPlugin ( Neos\ContentRepository\Domain\Model\NodeInterface $node, string $viewName ) : Neos\ContentRepository\Domain\Model\NodeInterface
$node Neos\ContentRepository\Domain\Model\NodeInterface
$viewName string
return Neos\ContentRepository\Domain\Model\NodeInterface
    public function getPluginViewNodeByMasterPlugin(NodeInterface $node, $viewName)
    {
        /** @var $context ContentContext */
        $context = $node->getContext();
        foreach ($this->getNodes(['Neos.Neos:PluginView'], $context) as $pluginViewNode) {
            /** @var NodeInterface $pluginViewNode */
            if ($pluginViewNode->isRemoved()) {
                continue;
            }
            if ($pluginViewNode->getProperty('plugin') === $node->getIdentifier() && $pluginViewNode->getProperty('view') === $viewName) {
                return $pluginViewNode;
            }
        }
        return null;
    }

Usage Example

 /**
  * 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);
 }