Create NodeUri in PHP backend

Hello,

I basically want to use a php Eel-Helper to do the same that Neos.Neos:NodeUri does in a Fusionfile (i.e. give me the uri of a node). The reason behind this is that I am using the Elasticsearch-Plugin and want to add the complete path of a Node to the Index.
The yaml of the Node to be indexed looks like this:

But I am a bit lost as to how to implement the createUri-Function. I’ve tried some things already, latest version being this:

But it doesn’t work (Iww\NodeTypes\Eel\Helper\Indexing_Original::createUri(): Return value must be of type string, null returned) and I feel like I am missing something - can anyone help?

Greetings,

Sabine

Hi,

are you using this helper? outofbandrendering/Classes/Service/ContextBuilder.php at master · punktDe/outofbandrendering · GitHub

Then you need to provide a valid baseUri via configuration if it cannot be retrieved from the request.

With that ControllerContext you can use the UriBuilder.

1 Like

Hi,

I am using my own helper as I don’t see how this Helper could help me . I experimented with it but found no good way to use it for my purposes (generating the uri of a node and index it to elastic). How would you use this helper in this situation, could you maybe give some pinters?

Greetings,

Sabine

You can just use this helper as inspiration on how to build the proper context for the uri builder, then you need to check the logs if no Uri is generated. It should contain a hint on what’s going on.

1 Like

building uris is not trivial as it usually requires to have the current flow ActionRequest at hand (to determine the current host and routing parameters and stuff, see RFC CLI compatible context for uri building · Issue #3354 · neos/flow-development-collection · GitHub)

to successfully build a node uri ONLY with a Node at hand without further input from outside we have to ask ourselves a few things:

  1. do we want host absolute (https://localhost) or host relative urls /?
  2. to determine the host for host absolute uri building we have to assume that the matching site entity has a connected domain

Is point 2 correct in your case? see flow site:list and flow domain:list

Also as we are working in 9.0 on an overhauled uri building !!! FEATURE: Overhaul node uri building by mhsdesign · Pull Request #4892 · neos/neos-development-collection · GitHub please note that this knowledge does not apply 1to1 to Neos 9.

1 Like

Hi, I got the solution, it is way simpler than my way. It helped looking at the OutOfBandRenderer, thanks for the suggestion.

My solution now looks like this:

I used the CreateContentContextTrait for this.

Thanks for your help!

Greetings,

Sabine