1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Abstract form renderer |
4
|
|
|
* |
5
|
|
|
* @category StrokerForm |
6
|
|
|
* @package StrokerForm\Renderer |
7
|
|
|
* @copyright 2012 Bram Gerritsen |
8
|
|
|
* @version SVN: $Id$ |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace StrokerForm\Renderer; |
12
|
|
|
|
13
|
|
|
use StrokerForm\FormManager; |
14
|
|
|
use Zend\I18n\Translator\TranslatorAwareInterface; |
15
|
|
|
use Zend\I18n\Translator\TranslatorAwareTrait; |
16
|
|
|
use Zend\Mvc\Router\RouteInterface; |
17
|
|
|
use Zend\Stdlib\AbstractOptions; |
18
|
|
|
|
19
|
|
|
abstract class AbstractRenderer implements RendererInterface, TranslatorAwareInterface |
20
|
|
|
{ |
21
|
|
|
use TranslatorAwareTrait; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \Zend\Mvc\Router\RouteInterface |
25
|
|
|
*/ |
26
|
|
|
protected $httpRouter; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var AbstractOptions |
30
|
|
|
*/ |
31
|
|
|
protected $defaultOptions = []; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var Options |
35
|
|
|
*/ |
36
|
|
|
protected $options = null; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var FormManager |
40
|
|
|
*/ |
41
|
|
|
protected $formManager; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return RouteInterface |
45
|
|
|
*/ |
46
|
|
|
public function getHttpRouter() |
47
|
|
|
{ |
48
|
|
|
return $this->httpRouter; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param RouteInterface $httpRouter |
53
|
|
|
* |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
|
|
public function setHttpRouter(RouteInterface $httpRouter) |
57
|
|
|
{ |
58
|
|
|
$this->httpRouter = $httpRouter; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return AbstractOptions |
63
|
|
|
*/ |
64
|
|
|
public function getOptions() |
65
|
|
|
{ |
66
|
|
|
return $this->options; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param array $options |
71
|
|
|
*/ |
72
|
|
|
public function setOptions(array $options = []) |
73
|
|
|
{ |
74
|
|
|
if ($this->options === null) { |
75
|
|
|
$this->options = clone $this->defaultOptions; |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
foreach ($options as $key => $value) { |
79
|
|
|
if (isset($this->options->{$key}) && is_array($this->options->{$key})) { |
80
|
|
|
$options[$key] = $this->options->mergeRecursive($this->options->{$key}, $value); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$this->options->setFromArray($options); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param AbstractOptions $options |
89
|
|
|
*/ |
90
|
|
|
public function setDefaultOptions(AbstractOptions $options = null) |
91
|
|
|
{ |
92
|
|
|
$this->defaultOptions = $options; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return FormManager |
97
|
|
|
*/ |
98
|
|
|
public function getFormManager() |
99
|
|
|
{ |
100
|
|
|
return $this->formManager; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param FormManager $formManager |
105
|
|
|
*/ |
106
|
|
|
public function setFormManager(FormManager $formManager) |
107
|
|
|
{ |
108
|
|
|
$this->formManager = $formManager; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.