1 | <?php |
||
17 | class Resource extends MagicResource implements ResourceInterface |
||
18 | { |
||
19 | protected $allowed = []; |
||
20 | |||
21 | protected $allowedValues = []; |
||
22 | |||
23 | protected $mandatory = []; |
||
24 | |||
25 | protected $defaults = []; |
||
26 | |||
27 | protected $rules = []; |
||
28 | |||
29 | protected $rewrites = []; |
||
30 | |||
31 | protected $ranges = []; |
||
32 | |||
33 | 7 | public function mandatory() |
|
37 | |||
38 | 4 | public function allowed() |
|
42 | |||
43 | 6 | public function allowedValues() |
|
47 | |||
48 | 9 | public function rules() |
|
52 | |||
53 | public function defaults() |
||
54 | { |
||
55 | return $this->defaults; |
||
56 | } |
||
57 | |||
58 | 8 | public function rewrites() |
|
62 | |||
63 | 8 | public function ranges() |
|
67 | |||
68 | public function applyConfiguration( |
||
69 | Configurator $configurator |
||
70 | ) { |
||
71 | $this->allowed = $configurator->allowed(); |
||
72 | $this->mandatory = $configurator->mandatory(); |
||
73 | $this->defaults = $configurator->defaults(); |
||
74 | $this->rules = $configurator->rules(); |
||
75 | $this->allowedValues = $configurator->allowedValues(); |
||
76 | $this->rewrites = $configurator->rewrites(); |
||
77 | $this->ranges = $configurator->ranges(); |
||
78 | |||
79 | if ($configurator->globals()) { |
||
80 | $globals = $configurator->globals(); |
||
81 | if (isset($globals['allowed'])) { |
||
82 | $this->allowed = array_merge( |
||
83 | $this->allowed, |
||
84 | $globals['allowed'] |
||
85 | ); |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 | |||
90 | 12 | public function isRuleDefinedFor($ruleName) |
|
94 | |||
95 | 12 | public function isRuleNotDefinedFor($ruleName) |
|
99 | |||
100 | 5 | public function getRule($ruleName) : Rule |
|
106 | |||
107 | 1 | public function isFieldNumeric($fieldName) |
|
111 | |||
112 | public function isFieldString($fieldName) |
||
113 | { |
||
114 | return is_string($this->get($fieldName)); |
||
115 | } |
||
116 | |||
117 | 1 | public function isFieldNumericButString($fieldName) |
|
122 | |||
123 | 5 | public function getFieldType($fieldName) |
|
127 | } |
||
128 |