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 Zend\I18n\Translator\TranslatorAwareInterface; |
14
|
|
|
use Zend\I18n\Translator\Translator; |
15
|
|
|
use Zend\I18n\Translator\TranslatorAwareTrait; |
16
|
|
|
use Zend\I18n\Translator\TranslatorInterface; |
17
|
|
|
use Zend\Mvc\Router\RouteInterface; |
18
|
|
|
use Zend\Stdlib\AbstractOptions; |
19
|
|
|
use StrokerForm\FormManager; |
20
|
|
|
|
21
|
|
|
abstract class AbstractRenderer implements RendererInterface, TranslatorAwareInterface |
22
|
|
|
{ |
23
|
|
|
use TranslatorAwareTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \Zend\Mvc\Router\RouteInterface |
27
|
|
|
*/ |
28
|
|
|
protected $httpRouter; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var AbstractOptions |
32
|
|
|
*/ |
33
|
|
|
protected $defaultOptions = array(); |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var Options |
37
|
|
|
*/ |
38
|
|
|
protected $options = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var FormManager |
42
|
|
|
*/ |
43
|
|
|
protected $formManager; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return RouteInterface |
47
|
|
|
*/ |
48
|
|
|
public function getHttpRouter() |
49
|
|
|
{ |
50
|
|
|
return $this->httpRouter; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param RouteInterface $httpRouter |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function setHttpRouter(RouteInterface $httpRouter) |
58
|
|
|
{ |
59
|
|
|
$this->httpRouter = $httpRouter; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return AbstractOptions |
64
|
|
|
*/ |
65
|
|
|
public function getOptions() |
66
|
|
|
{ |
67
|
|
|
return $this->options; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param array $options |
72
|
|
|
*/ |
73
|
|
|
public function setOptions(array $options = array()) |
74
|
|
|
{ |
75
|
|
|
if ($this->options === null) { |
76
|
|
|
$this->options = clone $this->defaultOptions; |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
foreach ($options as $key => $value) { |
80
|
|
|
if (isset($this->options->{$key}) && is_array($this->options->{$key})) { |
81
|
|
|
$options[$key] = $this->options->mergeRecursive($this->options->{$key}, $value); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$this->options->setFromArray($options); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param AbstractOptions $options |
90
|
|
|
*/ |
91
|
|
|
public function setDefaultOptions(AbstractOptions $options = null) |
92
|
|
|
{ |
93
|
|
|
$this->defaultOptions = $options; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return FormManager |
98
|
|
|
*/ |
99
|
|
|
public function getFormManager() |
100
|
|
|
{ |
101
|
|
|
return $this->formManager; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param FormManager $formManager |
106
|
|
|
*/ |
107
|
|
|
public function setFormManager(FormManager $formManager) |
108
|
|
|
{ |
109
|
|
|
$this->formManager = $formManager; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
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.