mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 07:14:58 +00:00
Continue work on ACL rewritting
* fix center resolver dispatcher * add scope resolver * tests for authorization helper
This commit is contained in:
@@ -4,12 +4,13 @@ namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\HasCentersInterface;
|
||||
|
||||
class DefaultCenterResolver implements CenterResolverInterface
|
||||
{
|
||||
public function supports($entity, ?array $options = []): bool
|
||||
{
|
||||
return $entity instanceof HasCenterInterface;
|
||||
return $entity instanceof HasCenterInterface || $entity instanceof HasCentersInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,13 @@ class DefaultCenterResolver implements CenterResolverInterface
|
||||
*/
|
||||
public function resolveCenter($entity, ?array $options = [])
|
||||
{
|
||||
return $entity->getCenter();
|
||||
if ($entity instanceof HasCenterInterface) {
|
||||
return $entity->getCenter();
|
||||
} elseif ($entity instanceof HasCentersInterface) {
|
||||
return $entity->getCenters();
|
||||
} else {
|
||||
throw new \UnexpectedValueException("should be an instanceof");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDefaultPriority(): int
|
||||
|
Reference in New Issue
Block a user