public function preValidate(PreWriteValidationEvent
$event): void
{ $commands =
$event->
getCommands();
foreach ($commands as $command) { $violations =
new ConstraintViolationList();
if ($command instanceof CascadeDeleteCommand ||
$command->
getDefinition()->
getClass() !== LanguageDefinition::
class) { continue;
} $pk =
$command->
getPrimaryKey();
$id =
mb_strtolower(Uuid::
fromBytesToHex($pk['id'
]));
if ($command instanceof DeleteCommand &&
$id === Defaults::LANGUAGE_SYSTEM
) { $violations->
add( $this->
buildViolation( 'The default language {{ id }} cannot be deleted.',
['{{ id }}' =>
$id],
'/' .
$id,
$id,
self::VIOLATION_DELETE_DEFAULT_LANGUAGE
) );