/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/authorization/src/Policy
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/authorization/src/Policy/ResolverCollection.php (2570B)
ServicePolicy::class
* ])
* ]);
*
* $service = new AuthorizationService($collection);
* ```
*/
class ResolverCollection implements ResolverInterface
{
/**
* Policy resolver instances.
*
* @var \Authorization\Policy\ResolverInterface[]
*/
protected $resolvers = [];
/**
* Constructor. Takes an array of policy resolver instances.
*
* @param \Authorization\Policy\ResolverInterface[] $resolvers An array of policy resolver instances.
*/
public function __construct(array $resolvers = [])
{
foreach ($resolvers as $resolver) {
$this->add($resolver);
}
}
/**
* Adds a resolver to the collection.
*
* @param \Authorization\Policy\ResolverInterface $resolver Resolver instance.
* @return $this
*/
public function add(ResolverInterface $resolver)
{
$this->resolvers[] = $resolver;
return $this;
}
/**
* @inheritDoc
*/
public function getPolicy($resource)
{
foreach ($this->resolvers as $resolver) {
try {
return $resolver->getPolicy($resource);
} catch (MissingPolicyException $e) {
}
}
throw new MissingPolicyException($resource);
}
}