mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-17 12: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:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\HasScopesInterface;
|
||||
|
||||
class DefaultScopeResolver implements ScopeResolverInterface
|
||||
{
|
||||
|
||||
public function supports($entity, ?array $options = []): bool
|
||||
{
|
||||
return $entity instanceof HasScopeInterface || $entity instanceof HasScopesInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* @param HasScopeInterface|HasScopesInterface $entity
|
||||
*/
|
||||
public function resolveScope($entity, ?array $options = [])
|
||||
{
|
||||
if ($entity instanceof HasScopeInterface) {
|
||||
return $entity->getScope();
|
||||
} elseif ($entity instanceof HasScopesInterface) {
|
||||
return $entity->getScopes();
|
||||
} else {
|
||||
throw new \UnexpectedValueException("should be an instanceof %s or %s",
|
||||
HasScopesInterface::class, HasScopeInterface::class);
|
||||
}
|
||||
}
|
||||
|
||||
public function isConcerned($entity, ?array $options = []): bool
|
||||
{
|
||||
return $entity instanceof HasScopeInterface || $entity instanceof HasScopesInterface;
|
||||
}
|
||||
|
||||
public static function getDefaultPriority(): int
|
||||
{
|
||||
return -256;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user