[SOLVED] Extend NodeData Repository


I would like to create my own function for the node data repository (\Neos\ContentRepository\Domain\Repository\NodeDataRepository). So I have to extend it, but how does this work? I can’t find any doc of it.

Kind regards,

Hi Michael,

could you share what your problem is, i.e. what you want to achieve?

Hi Bastian,

I would like to create a new repository function that returns nodes by the node type. I created a new node type and a plugin. And the plugin should list all nodes of the type “Foo.Website:Article”.

I thought it wouldn’t be that hard to extend an existing Neos/Flow class. :see_no_evil:

That is the task of a flowquery q(site).find('instanceof Foo.Website:Article') or something similar directly in your Fusion document.

@lmis The NodeInterface of the ContentRepository Package is a very low-level API to the CR. You can use custom implementations but I would strongly discourage that in almost all situations because there are easier and more maintainable ways to do this.

If you just need to filter some nodes, that’s certainly nothing you need to change the implementation API for .
As @sorenmalling wrote, you can use FlowQuery for that.

So for example in the Fusion Prototype definition of your plugin sth like:

prototype(Some.Package:SomePlugin) < prototype(Neos.Neos:Plugin) {
    package = 'Some.Package'
    # ...
    articleNodes = ${q(site).find('instanceof Foo.Website:Article').get()}

And now you can access this node list from your plugin controller via

Alternatively you could for example use the NodeSearchService from PHP directly:

 * @Flow\Inject
 * @var ContextFactoryInterface
protected $contextFactory;

 * @Flow\Inject
 * @var NodeSearchService
protected $nodeSearchService;

private function getArticleNodes(string $searchTerm): array
    $liveContext = $this->contextFactory->create();
    return $this->nodeSearchService->findByProperties($searchTerm, ['Foo.Website:Article'], $liveContext);

Ok that’s interesting! Sorry, but I’m not that good in Fusion and Neos / Flow is kind of new to me. Thanks both of You! :slight_smile:

When I update my Fusion configuration of the plugin and add…
articleNodes = ${q(site).find('instanceof Foo.Website:Article').get()}
…to it, I’ll get an error:

The Selector “instanceof Foo.Website:Article” could not be parsed. Error at character 11.

Can You also tell me how I can archive that I only get the articles (Foo.Website:Article) of a special page? I created a property at my plugin, so that the user can select a node (page) where the articles should be listed from (recursively). Furthermore the articles should be sorted by their property ‘date’ (descending). Is this also possible via Fusion? I can’t find it in the documentation.

Hi @lmis

You are missing [] around the filter, like this find('[instanceof ..]') have a look here, about other operations you can do


Thanks @sorenmalling :+1:

Also the sorting works now :slight_smile: But how do I get only the articles under a special node (that I can configure in my plugin settings)? Furthermore I would like to know if I can use variables for the sorting? Like this:

prototype(Foo.Magazine:Plugin) < prototype(Neos.Neos:Plugin)
prototype(Foo.Magazine:Plugin) {
	package = 'Foo.Magazine'
	controller = 'Magazine'
	action = 'index'

	node = ${q(node).property('node')}
	sortproperty = ${q(node).property('sortproperty')}
	sortorder = ${q(node).property('sortorder')}

    articles = ${q(site).find('[instanceof Foo.Website:Article]').sort($sortproperty, $sortorder).get()}

You can add a property to your plugin node type (Foo.Magazine:Plugin) of the type reference. That will give you a node value you can use with

${q(site).find('#' + this.property).find([instanceof Foo.Website:Article]').sort(this.sortproperty, this.sortorder).get()}

Regarding sort see http://neos.readthedocs.io/en/stable/References/FlowQueryOperationReference.html#sort

Alternatively you might wanna look into plugin views where you have a master plugin on one page and a plugin view on another page referencing the master plugin to find data. See http://neos.readthedocs.io/en/stable/ExtendingNeos/CreatingAPlugin.html#configuring-a-plugin-to-show-specific-actions-on-different-pages

Hi @aertmann,
thanks for Your help, it works! :slight_smile: :+1: