Neos\Neos\Service\PluginService::getPluginNodesWithViewDefinitions PHP Method

getPluginNodesWithViewDefinitions() public method

Returns an array of all plugin nodes with View Definitions
public getPluginNodesWithViewDefinitions ( ContentContext $context ) : array
$context Neos\Neos\Domain\Service\ContentContext
return array
    public function getPluginNodesWithViewDefinitions(ContentContext $context)
    {
        $pluginNodes = [];
        foreach ($this->getPluginNodes($context) as $pluginNode) {
            /** @var NodeInterface $pluginNode */
            if ($this->getPluginViewDefinitionsByPluginNodeType($pluginNode->getNodeType()) !== []) {
                $pluginNodes[] = $pluginNode;
            }
        }
        return $pluginNodes;
    }

Usage Example

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