Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Classes/ContentRepository/CommandHook/TranslationCommandHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Sitegeist\LostInTranslation\ContentRepository\CommandHook;

use Behat\Transliterator\Transliterator;
use Neos\ContentRepository\Core\CommandHandler\CommandHookInterface;
use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\CommandHandler\Commands;
Expand Down Expand Up @@ -116,6 +117,8 @@ public function createNodeVariantCommandWasHandled(CreateNodeVariant $command):
return Commands::createEmpty();
}

$translatedProperties = $this->handleSpecialProperties($translatedProperties);

$newCommand = SetNodeProperties::create(
$command->workspaceName,
$command->nodeAggregateId,
Expand All @@ -125,4 +128,17 @@ public function createNodeVariantCommandWasHandled(CreateNodeVariant $command):

return Commands::fromArray([$newCommand]);
}

/**
* @param array<string,string> $translatedProperties
* @return array<string,string>
*/
private function handleSpecialProperties(array $translatedProperties): array
{
if (!empty($translatedProperties['uriPathSegment'])) {
$translatedProperties['uriPathSegment'] = Transliterator::urlize($translatedProperties['uriPathSegment']);
}

return $translatedProperties;
}
}