1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Defines all possible options for the module |
4
|
|
|
* |
5
|
|
|
* @category StrokerForm |
6
|
|
|
* @package StrokerForm\Options |
7
|
|
|
* @copyright 2012 Bram Gerritsen |
8
|
|
|
* @version SVN: $Id$ |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace StrokerForm\Options; |
12
|
|
|
|
13
|
|
|
use Zend\Stdlib\AbstractOptions; |
14
|
|
|
use Zend\ServiceManager\ConfigInterface; |
15
|
|
|
use Zend\ServiceManager\Config; |
16
|
|
|
use \InvalidArgumentException; |
17
|
|
|
|
18
|
|
|
class ModuleOptions extends AbstractOptions |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var array |
22
|
|
|
*/ |
23
|
|
|
private $activeRenderers = array(); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
private $forms = array(); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var array |
32
|
|
|
*/ |
33
|
|
|
private $rendererOptions = array(); |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
|
|
public function getActiveRenderers() |
39
|
|
|
{ |
40
|
|
|
return $this->activeRenderers; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param array |
45
|
|
|
*/ |
46
|
|
|
public function setActiveRenderers(array $activeRenderers) |
47
|
|
|
{ |
48
|
|
|
$this->activeRenderers = $activeRenderers; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return Config |
53
|
|
|
* @throws InvalidArgumentException |
54
|
|
|
*/ |
55
|
|
|
public function getForms() |
56
|
|
|
{ |
57
|
|
|
if (is_array($this->forms)) { |
58
|
|
|
$this->forms = new Config($this->forms); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if (!$this->forms instanceof ConfigInterface) { |
62
|
|
|
throw new InvalidArgumentException('Plugins argument must be an array or instanceof Zend\ServiceManager\ConfigInterface'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $this->forms; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param array $forms |
70
|
|
|
*/ |
71
|
|
|
public function setForms($forms) |
72
|
|
|
{ |
73
|
|
|
$this->forms = $forms; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param array $options |
78
|
|
|
*/ |
79
|
|
|
public function setRendererOptions(array $options) |
80
|
|
|
{ |
81
|
|
|
$this->rendererOptions = array(); |
82
|
|
|
foreach ($options as $renderer => $rendererOptions) { |
83
|
|
|
$this->addRendererOptions($renderer, $rendererOptions); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param string $renderer |
89
|
|
|
* @param array $options |
90
|
|
|
* @throws \InvalidArgumentException |
91
|
|
|
*/ |
92
|
|
|
public function addRendererOptions($renderer, $options) |
93
|
|
|
{ |
94
|
|
|
if (!is_array($options)) { |
95
|
|
|
throw new \InvalidArgumentException('No options given for renderer ' . $renderer); |
96
|
|
|
} |
97
|
|
|
if (!isset($options['options_class'])) { |
98
|
|
|
throw new \InvalidArgumentException('No options_class configured for renderer ' . $renderer); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
$optionsClass = $options['options_class']; |
102
|
|
|
unset($options['options_class']); |
103
|
|
|
$options = new $optionsClass($options); |
104
|
|
|
|
105
|
|
|
$this->rendererOptions[$renderer] = $options; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $renderer |
110
|
|
|
* @return null|AbstractOptions |
111
|
|
|
* @throws \InvalidArgumentException |
112
|
|
|
*/ |
113
|
|
|
public function getRendererOptions($renderer) |
114
|
|
|
{ |
115
|
|
|
return $this->rendererOptions[$renderer]; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..