mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
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:
parent
d9b36533a2
commit
27df3b2c9b
@ -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
|
||||
{
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
/**
|
||||
* Center resolver which need the CenterResolverManager.
|
||||
*
|
||||
* Appended to @see{CenterResolverInterface} which needs the @{CenterResolverManager} to resolve the center
|
||||
*/
|
||||
interface ManagerAwareCenterResolverInterface
|
||||
{
|
||||
public function setResolverManager(CenterResolverManagerInterface $manager): void;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
trait ManagerAwareCenterResolverTrait
|
||||
{
|
||||
protected CenterResolverManagerInterface $centerResolverManager;
|
||||
|
||||
public function setResolverManager(CenterResolverManagerInterface $manager): void
|
||||
{
|
||||
$this->centerResolverManager = $manager;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user