/**
* @param list<array{entity: string, value: string|null, definition: EntityDefinition, field: Field|null}> $pathSegments
* @param array<string> $protections FQCN of the protections that need to be validated
*/
public function validateEntityPath(array
$pathSegments, array
$protections, Context
$context): void
{ foreach ($pathSegments as $pathSegment) { /** @var EntityDefinition $definition */
$definition =
$pathSegment['definition'
];
foreach ($protections as $protection) { $protectionInstance =
$definition->
getProtections()->
get($protection);
if (!
$protectionInstance ||
$protectionInstance->
isAllowed($context->
getScope())) { continue;
} throw new AccessDeniedHttpException( sprintf('API access for entity "%s" not allowed.',
$pathSegment['entity'
]) );
} } }