Add support for ManagerAwareCenterResolverInterface

Introduce ManagerAwareCenterResolverInterface to ensure resolvers can reference their manager. Added a trait for implementing the interface and updated the CenterResolverManager to initialize resolvers correctly.
This commit is contained in:
2024-09-24 10:58:01 +02:00
parent d9b36533a2
commit 27df3b2c9b
3 changed files with 52 additions and 1 deletions

View File

@@ -18,7 +18,14 @@ final readonly class CenterResolverManager implements CenterResolverManagerInter
/**
* @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers
*/
public function __construct(private iterable $resolvers = []) {}
public function __construct(private iterable $resolvers = [])
{
foreach ($resolvers as $resolver) {
if ($resolver instanceof ManagerAwareCenterResolverInterface) {
$resolver->setResolverManager($this);
}
}
}
public function resolveCenters($entity, ?array $options = []): array
{