Open hphoeksma opened 1 year ago
fine by reading
I need to take a closer look at this case. If a language is configured to sync from another language, then nodes would automatically be adopted, without having to switch the language in the dimension switcher and hit “create and copy”.
I need to take a closer look at this case. If a language is configured to sync from another language, then nodes would automatically be adopted, without having to switch the language in the dimension switcher and hit “create and copy”.
Not sure what you mean. Do you mean when creating a new dimension preset the whole tree should be created? Because that isn't the case.
I created a command (in a separate package) that clones the whole node tree based on given dimensions and target dimensions and in that case the whole tree gets created, but without this fix nothing gets translated.
Sorry for the late reply.
If the configuration is set to sync, then the nodes are adopted/synced automatically as soon as the node in the source language is changed and published. But I don't know right now how it behaves if you change the configuration later when there is already content. E.g., you add another language dimension.
For that case, I wrote a sync command which can sync the whole content tree for a language. However, I did not publish it yet. I think this would be the better approach, wouldn't it? Say like you add another language dimension, and then you run the command to have a fully synchronized new language dimension.
Your PR is not wrong, though, but it would require doing the creation process through the language switcher for every document.
What do you mean?
Sorry for the late reply.
No problem.
If the configuration is set to sync, then the nodes are adopted/synced automatically as soon as the node in the source language is changed and published.
Somehow we had issues with this, which might be due to our setup (multiple dimensions - country & language). I think what I ran into was documents being created and translated fine, but not the contents (which is done using adopting). That is why when syncing this should be run as well I think...?
Adding a new dimension set definitely did not work and I created a command to sync from one set to another set - I guess similar as you.
Mine looks like this:
public function syncTree(string $siteNodeName, array $from, array $to): void
{
$from = json_decode(reset($from), true);
$targetDimensions = json_decode(reset($to), true);
/** @var Context $context */
$context = $this->getContext('live', $from);
$siteNode = $context->getNode('/sites/' . $siteNodeName);
if (!$siteNode) {
$this->output->outputLine('The sitenode could not be found, please check if you have the correct siteNodeName and if the from dimensions are available in your configuration.');
$this->quit();
}
$documentNodeQuery = new FlowQuery([$siteNode]);
$documentNodeQuery->pushOperation('find', ['[instanceof Neos.Neos:Document]']);
$documentNodes = $documentNodeQuery->get();
array_unshift($documentNodes, $siteNode);
$this->output->outputLine('Found %s document nodes', [sizeof($documentNodes)]);
$this->output->progressStart(sizeof($documentNodes));
$newContext = $this->getContext('live', $targetDimensions);
/** @var NodeInterface $documentNode */
foreach ($documentNodes as $documentNode) {
$newContext->adoptNode($documentNode, true);
$this->nodeDataRepository->persistEntities();
$this->output->progressAdvance();
}
$this->output->progressFinish();
$this->quit();
}
Fixes #28