mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
Continue work on ACL rewritting
* fix center resolver dispatcher * add scope resolver * tests for authorization helper
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
|
||||
final class ScopeResolverDispatcher
|
||||
{
|
||||
/**
|
||||
* @var iterable|ScopeResolverInterface[]
|
||||
*/
|
||||
private iterable $resolvers;
|
||||
|
||||
public function __construct(iterable $resolvers)
|
||||
{
|
||||
$this->resolvers = $resolvers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $entity
|
||||
* @return Scope|Scope[]|iterable
|
||||
*/
|
||||
public function resolveScope($entity, ?array $options = [])
|
||||
{
|
||||
foreach ($this->resolvers as $resolver) {
|
||||
if ($resolver->supports($entity, $options)) {
|
||||
return $resolver->resolveScope($entity, $options);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function isConcerned($entity, ?array $options = []): bool
|
||||
{
|
||||
foreach ($this->resolvers as $resolver) {
|
||||
if ($resolver->supports($entity, $options)) {
|
||||
return $resolver->isConcerned($entity, $options);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user