use OAuth2Framework\Component\Server\Model\DataBag\DataBag;
18
use OAuth2Framework\Component\Server\Model\Scope\ScopePolicyManager;
19
use OAuth2Framework\Component\Server\Model\UserAccount\UserAccountId;
20
21
final class ScopePolicyRule implements RuleInterface
22
{
23
/**
24
* @var ScopePolicyManager
25
*/
26
private $scopePolicyManager;
27
28
/**
29
* @param ScopePolicyManager $scopePolicyManager
30
*/
31
public function __construct(ScopePolicyManager $scopePolicyManager)
32
{
33
$this->scopePolicyManager = $scopePolicyManager;
34
}
35
36
/**
37
* {@inheritdoc}
38
*/
39
public function handle(DataBag $commandParameters, DataBag $validatedParameters, ?UserAccountId $userAccountId, callable $next): DataBag
40
{
41
if ($commandParameters->has('scope_policy')) {
42
Assertion::true($this->scopePolicyManager->has($commandParameters->get('scope_policy')), sprintf('The scope policy \'%s\' is not supported.', $commandParameters->get('scope_policy')));