1 | <?php |
||
8 | class ObjectConfig extends AbstractConfig |
||
9 | { |
||
10 | /** |
||
11 | * Owner of this configuration object |
||
12 | * |
||
13 | * @var object |
||
14 | */ |
||
15 | private $owner = null; |
||
16 | /** |
||
17 | * Configuration options for to serve by this configuration object |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | private $options; |
||
22 | /** |
||
23 | * Configuration class Id for this configuration object |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private $classId = null; |
||
28 | /** |
||
29 | * List of registered callbacks for customizing configuration object behavior |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | private $callbacks = [ |
||
34 | 'validateConfig' => null, // Custom implementation of validateConfig() |
||
35 | 'onConfigChange' => null, // Custom implementation of onConfigChange() |
||
36 | 'lazyConfigInit' => null, // Custom implementation of lazyConfigInit() |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Class constructor |
||
41 | * |
||
42 | * @param object $owner Owner of this configuration object |
||
43 | * @param array $options List of configuration options to serve (@see AbstractConfig::initConfig for description) |
||
44 | * @param array $callbacks OPTIONAL List of callbacks to customize configuration object behavior |
||
45 | * @param array $config OPTIONAL Configuration options to initialize class with |
||
46 | * @throws \InvalidArgumentException |
||
47 | */ |
||
48 | 24 | public function __construct($owner, array $options, array $callbacks = [], array $config = []) |
|
68 | |||
69 | /** |
||
70 | * Set owner of this configuration object |
||
71 | * |
||
72 | * @param object $owner Owner of this configuration object |
||
73 | * @throws \InvalidArgumentException |
||
74 | * @return void |
||
75 | */ |
||
76 | 24 | protected function setOwner($owner) |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 20 | protected function getConfigClassId() |
|
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | 20 | protected function initConfig() |
|
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | 19 | protected function validateConfig($name, &$value) |
|
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | 6 | protected function onConfigChange($name, $value) |
|
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | 14 | protected function lazyConfigInit($name) |
|
140 | } |
||
141 |