-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractGuardsProvider.php
54 lines (46 loc) · 1.36 KB
/
AbstractGuardsProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @see https://github.com/dotkernel/dot-rbac-guard/ for the canonical source repository
* @copyright Copyright (c) 2017 Apidemia (https://www.apidemia.com)
* @license https://github.com/dotkernel/dot-rbac-guard/blob/master/LICENSE.md MIT License
*/
declare(strict_types = 1);
namespace Dot\Rbac\Guard\Provider;
use Dot\Rbac\Guard\Exception\RuntimeException;
use Dot\Rbac\Guard\Guard\Factory;
/**
* Class AbstractGuardsProvider
* @package Dot\Rbac\Guard\Provider
*/
abstract class AbstractGuardsProvider implements GuardsProviderInterface
{
/** @var Factory */
protected $guardFactory;
/**
* AbstractGuardsProvider constructor.
* @param array $options
*/
public function __construct(array $options = [])
{
if (isset($options['guard_factory']) && $options['guard_factory'] instanceof Factory) {
$this->setGuardFactory($options['guard_factory']);
}
if (!$this->guardFactory instanceof Factory) {
throw new RuntimeException('Guard factory is required and was not set');
}
}
/**
* @return Factory
*/
public function getGuardFactory(): Factory
{
return $this->guardFactory;
}
/**
* @param Factory $guardFactory
*/
public function setGuardFactory(Factory $guardFactory)
{
$this->guardFactory = $guardFactory;
}
}