neos / neos-development-collection

The unified repository containing the Neos core packages, used for Neos development.
https://www.neos.io/
GNU General Public License v3.0
266 stars 222 forks source link

FEATURE: Add helpers to fetch nodes in ways similar to `context()` operation #5100

Open kdambekalns opened 6 months ago

kdambekalns commented 6 months ago

Description

Prior to Neos 9 it was possible to use the context() operation to fetch nodes, e.g. from a different workspace or in different dimension values. This was useful e.g. if you need to create a link to such a node.

With Neos 9 the context() operation no longer exists, a new, possibly improved way should be made available.

Ideally the new way could be added to a potential Neos 8.4 to make it forward-compatible.

Current state

In Neos9-beta10 and before a hard to decipher error is shown, indicating that context does not exist.

Method "context" is not callable in untrusted context

Possible Solution

kdambekalns commented 6 months ago

I'm willing to coordinate and hopefully implement this. I need your help, though, to come up with a nice API. So let's hear your suggestions for the operations we need…

Sebobo commented 6 months ago

I use the same three as in your list. So here my first quick suggestions:

How about withDimensionsCombination(<dimensions>[, <targetDimensions>]) for something like this:

q(site).context({'dimensions': this.dimensions.dimensions, 'targetDimensions': this.dimensions.targetDimensions})

And includeInvisible([<bool>]) to replace q(node).context({'invisibleContentShown': true})

mhsdesign commented 6 months ago

regarding legacy invisibleContentShown:

Regarding includeInvisible([<bool>]) we should definitely use the disabled naming here (https://github.com/neos/neos-development-collection/issues/4312) and we actually prepared with the introduction of subtree tags new possibilities than just disabled and not disabled but also custom subtree tags. That should ideally be also reflected via the api but there might be an abstraction to simplify the disabled case:

q(node).withoutDisabled()
q(node).withDisabled()

and generic tags:

q(node).withRestrictedVisibility([])
q(node).withRestrictedVisibility(['disabled'])

i found it actually super hard to think of the namings here and until bastians cr privileges are done it might be to soon to advance here ... unless of course well coordinated.

regarding targetDimensions

i have to ask bernhard but one just uses a full dimension space point here ... so the api would be

withDimension(['language' => 'en'])

Fyi regarding dimension we already also have this eel helper in place which can do a lot of crazy stuff (for neos seo)

Neos.Dimension.findVariantInDimension(node, 'language', 'en_UK')
kdambekalns commented 6 months ago

TIL: Node.Dimension.…, see e.g. https://github.com/neos/neos-seo/blob/4.x/Resources/Private/Fusion/Metadata/AlternateLanguageLinks.fusion

mhsdesign commented 5 months ago

https://github.com/neos/neos-development-collection/pull/5130 would reintroduce the 8.3 syntax for workspaceName, dimensions, invisibleContentShown (untested yet)