/**
* Yields the entity matching the criteria provided in the route.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jérémy Derussé <jeremy@derusse.com>
*/
final class EntityValueResolver implements ValueResolverInterface
{ public function __construct( private ManagerRegistry
$registry,
private ?ExpressionLanguage
$expressionLanguage = null,
private MapEntity
$defaults =
new MapEntity(),
) { } public function resolve(Request
$request, ArgumentMetadata
$argument): array
{ if (\
is_object($request->attributes->
get($argument->
getName()))) { return [];
} $options =
$argument->
getAttributes(MapEntity::
class, ArgumentMetadata::IS_INSTANCEOF
);
$options =
($options[0
] ??
$this->defaults
)->
withDefaults($this->defaults,
$argument->
getType());