|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* 2017 Romain CANON <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
7
|
|
|
* under the terms of the GNU General Public License, either |
|
8
|
|
|
* version 3 of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, see: |
|
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Romm\Formz\Form\Definition\Middleware; |
|
15
|
|
|
|
|
16
|
|
|
use Romm\Formz\Form\Definition\AbstractFormDefinitionComponent; |
|
17
|
|
|
use Romm\Formz\Middleware\Scope\MainScope; |
|
18
|
|
|
|
|
19
|
|
|
class MiddlewareScopes extends AbstractFormDefinitionComponent |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @todo desc |
|
23
|
|
|
* |
|
24
|
|
|
* List of interface names that do implement: |
|
25
|
|
|
* |
|
26
|
|
|
* @see \Romm\Formz\Middleware\Scope\ScopeInterface |
|
27
|
|
|
* |
|
28
|
|
|
* @var array |
|
29
|
|
|
* @validate NotEmpty |
|
30
|
|
|
* @todo validation type |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $whiteList = []; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @todo desc |
|
36
|
|
|
* |
|
37
|
|
|
* List of interface names that do implement: |
|
38
|
|
|
* |
|
39
|
|
|
* @see \Romm\Formz\Middleware\Scope\ScopeInterface |
|
40
|
|
|
* |
|
41
|
|
|
* @var array |
|
42
|
|
|
* @todo validation type |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $blackList = []; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param array $whiteList |
|
48
|
|
|
* @param array $blackList |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(array $whiteList = [MainScope::class], array $blackList = []) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->whiteList = $whiteList; |
|
53
|
|
|
$this->blackList = $blackList; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param string $scope |
|
58
|
|
|
* @return bool |
|
59
|
|
|
*/ |
|
60
|
|
|
public function isWhiteListed($scope) |
|
61
|
|
|
{ |
|
62
|
|
|
return in_array($scope, $this->whiteList); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param string $scope |
|
67
|
|
|
* @return bool |
|
68
|
|
|
*/ |
|
69
|
|
|
public function isBlackListed($scope) |
|
70
|
|
|
{ |
|
71
|
|
|
return in_array($scope, $this->blackList); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|