Hey,
and another one from me… Again more in the category “it’s broken, let’s discuss how to fix it”.
So to set the stage I am working to allow references to nodes outside the current site. Now that basically isn’t hard, I have the change ready to push, but it has one bigger issue. It’s what to show in the backend for those nodes. Obviously the uriPath alone won’t be helpful for other sites and impossible for things that are not in a site at all.
I have some ideas what to show, but that pointed me to the actual issue I would like to discuss:
We cannot reliably link to other sites currently for several reasons:
The domain entity we have has a property hostPattern
, but can we trust it contains a valid domain?
How do we know which domain is the primary one?
This would be the first issue to solve. I am not entirely sure how ot proceed but I would suggest a primary flag (which actually should be mutually exclusive to being disabled) and transition to make hostPattern actually a host? Or add host additionally which is required for the primary domain?
Addition: The \TYPO3\Neos\Controller\Backend\MenuHelper::buildSiteList
method does linking to other sites, but to me that does look far from reliable…
Then we have a second problem: ContentContext holds currentSite and currentDomain and this information is used all over the place (link building for example), but it is created in a less than optimal way. Which results in link building that doesn’t work for other sites.
See, this code snippet is used in several places:
$currentDomain = $this->domainRepository->findOneByActiveRequest();
if ($currentDomain !== null) {
$contextProperties['currentSite'] = $currentDomain->getSite();
$contextProperties['currentDomain'] = $currentDomain;
} else {
$contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
}
This is fine for me in (incoming) routing as there we need to go by the current request, but it is for example also used in the NodeConverter and there it is IMHO wrong to do that as the result is not deterministic based on the input alone but depends on the request. I rather think we should derive the site from the node path given to the converter. I also have a change for that ready, but of course that is quite some change (even if mostly not noticeable). Same goes for any other places this type of code is used.
Pushed that here: https://github.com/neos/neos-development-collection/pull/133
Then the additional problem is how we can deal with getting nodes within an existing ContentContext (if you just got the path). Imagine you grab a node from a site that is not currentSite
. Then you got a node with a context that doesn’t fit together, which breaks link building (and probably other things as well).
IMHO we have two routes to go with ContentContext and I am not sure yet which I like more, I have to think scenarios through a bit more:
-
A ContentContext is deliberately about one specific site, any nodes outside of the
currentSite
are basically non existent for that context. Would be pretty consistent BUT make our lives VERY hard because we would have to build logic to switch contexts everywhere we create nodes (doable) and make sure we expect different contexts and everything not in a site would need to use a CR Context and cannot use a ContentContext. -
We basically “remove” currentSite from the ContentContext or treat it differently than we do now (really only as
current
and not the site all nodes belong to, which we do now). That would definitely mean it shouldn’t be part of the context properties anymore. I still need to see though the code what that would imply but I think it would be doable. This would make the ContentContext mostly a “place to grab some request specific information” but the context properties wouldn’t be different compared to the CR. The task would be to provide a central place that you can give a node and get the matching site (and domain) from.
As said, I wanted to start discussion about it without having a master plan yet. I like both options but I know that option 1 will make some things much harder as the context starts to depend on the node path in some way.
Especially for the basic idea behind the currentSite
I would llke to pull in @aertmann @kdambekalns @robert @christopher and @sebastian