mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
* fix center resolver dispatcher * add scope resolver * tests for authorization helper
33 lines
722 B
PHP
33 lines
722 B
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Security\Resolver;
|
|
|
|
class CenterResolverDispatcher
|
|
{
|
|
/**
|
|
* @var iterabble|CenterResolverInterface[]
|
|
*/
|
|
private iterable $resolvers = [];
|
|
|
|
public function __construct(iterable $resolvers)
|
|
{
|
|
$this->resolvers = $resolvers;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $entity
|
|
* @param array|null $options
|
|
* @return null|Center|Center[]
|
|
*/
|
|
public function resolveCenter($entity, ?array $options = [])
|
|
{
|
|
foreach($this->resolvers as $priority => $resolver) {
|
|
if ($resolver->supports($entity, $options)) {
|
|
return $resolver->resolveCenter($entity, $options);
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|