Total Complexity | 8 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | abstract class Container extends Element |
||
10 | { |
||
11 | protected $elements = array(); |
||
12 | |||
13 | /** |
||
14 | * @return string |
||
15 | */ |
||
16 | abstract protected function renderHead(); |
||
17 | |||
18 | /** |
||
19 | * @return string |
||
20 | */ |
||
21 | abstract protected function renderFoot(); |
||
22 | |||
23 | /** |
||
24 | * Method for adding an element to the form container. |
||
25 | * @return Container |
||
26 | */ |
||
27 | public function add(Element $element) |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * This method sets the data for the fields in this container. The parameter passed to this method is a structured |
||
34 | * array which has field names as keys and the values as value. |
||
35 | */ |
||
36 | public function setData($data) |
||
37 | { |
||
38 | if (is_array($data)) { |
||
39 | foreach ($this->elements as $element) { |
||
40 | $element->setData($data); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | |||
45 | public function render() |
||
46 | { |
||
47 | return $this->renderHead() |
||
48 | . $this->templateRenderer->render('elements.tpl.php', array('elements' => $this->getElements())) |
||
49 | . $this->renderFoot(); |
||
50 | } |
||
51 | |||
52 | public function getElements() |
||
53 | { |
||
54 | return $this->elements; |
||
55 | } |
||
56 | |||
57 | public function __toString() |
||
60 | } |
||
61 | |||
62 | public function isContainer() |
||
65 | } |
||
66 | } |
||
67 |