public static function getSubscribedEvents(): array
{ return [PreWriteValidationEvent::
class => 'preValidate'
];
} public function preValidate(PreWriteValidationEvent
$event): void
{ $context =
$event->
getContext();
$source =
$event->
getContext()->
getSource();
if ($source instanceof AdminSalesChannelApiSource
) { $context =
$source->
getOriginalContext();
$source =
$context->
getSource();
} if ($context->
getScope() === Context::SYSTEM_SCOPE || !
$source instanceof AdminApiSource ||
$source->
isAdmin()) { return;
} $commands =
$event->
getCommands();
$missingPrivileges =
[];
foreach ($commands as $command) {