1 | <?php |
||
21 | trait ConfigurationTrait |
||
22 | { |
||
23 | /** |
||
24 | * @inheritdoc \Interop\Config\RequiresConfig::dimensions |
||
25 | */ |
||
26 | abstract public function dimensions(); |
||
27 | |||
28 | /** |
||
29 | * Checks if options are available depending on implemented interfaces and checks that the retrieved options are an |
||
30 | * array or have implemented \ArrayAccess. |
||
31 | * |
||
32 | * The RequiresConfigId interface is supported. |
||
33 | * |
||
34 | * @param array|ArrayAccess $config Configuration |
||
35 | * @param string|null $configId Config name, must be provided if factory uses RequiresConfigId interface |
||
36 | * @return bool True if options are available, otherwise false |
||
37 | */ |
||
38 | 24 | public function canRetrieveOptions($config, $configId = null) |
|
61 | |||
62 | /** |
||
63 | * Returns options based on dimensions() like [vendor][package] and can perform mandatory option checks if |
||
64 | * class implements RequiresMandatoryOptions. If the ProvidesDefaultOptions interface is implemented, these options |
||
65 | * must be overridden by the provided config. If you want to allow configurations for more then one instance use |
||
66 | * RequiresConfigId interface. |
||
67 | * |
||
68 | * The RequiresConfigId interface is supported. |
||
69 | * |
||
70 | * @param array|ArrayAccess $config Configuration |
||
71 | * @param string $configId Config name, must be provided if factory uses RequiresConfigId interface |
||
72 | * @return array|ArrayAccess |
||
73 | * @throws Exception\InvalidArgumentException If the $configId parameter is provided but factory does not support it |
||
74 | * @throws Exception\UnexpectedValueException If the $config parameter has the wrong type |
||
75 | * @throws Exception\OptionNotFoundException If no options are available |
||
76 | * @throws Exception\MandatoryOptionNotFoundException If a mandatory option is missing |
||
77 | */ |
||
78 | 21 | public function options($config, $configId = null) |
|
119 | |||
120 | /** |
||
121 | * Checks if options can be retrieved from config and if not, default options (ProvidesDefaultOptions interface) or |
||
122 | * an empty array will be returned. |
||
123 | * |
||
124 | * @param array|ArrayAccess $config Configuration |
||
125 | * @param string $configId Config name, must be provided if factory uses RequiresConfigId interface |
||
126 | * @return array|ArrayAccess options Default options or an empty array |
||
127 | */ |
||
128 | 1 | public function optionsWithFallback($config, $configId = null) |
|
140 | |||
141 | /** |
||
142 | * Checks if a mandatory param is missing, supports recursion |
||
143 | * |
||
144 | * @param array|ArrayAccess $mandatoryOptions |
||
145 | * @param array|ArrayAccess $options |
||
146 | * @throws Exception\MandatoryOptionNotFoundException |
||
147 | */ |
||
148 | 6 | private function checkMandatoryOptions($mandatoryOptions, $options) |
|
168 | } |
||
169 |