1: <?php
2: /**
3: * PHP version 5
4: * @package generalDriver
5: * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
6: * @author Stefan Heimes <stefan_heimes@hotmail.com>
7: * @author Tristan Lins <tristan.lins@bit3.de>
8: * @copyright The MetaModels team.
9: * @license LGPL.
10: * @filesource
11: */
12:
13: namespace DcGeneral\Panel;
14:
15: use DcGeneral\Data\ConfigInterface;
16:
17: /**
18: * Default implementation of a panel row.
19: *
20: * @package DcGeneral\Panel
21: */
22: class DefaultPanel
23: implements PanelInterface
24: {
25: /**
26: * The panel container this panel is contained within.
27: *
28: * @var PanelContainerInterface
29: */
30: protected $objContainer;
31:
32: /**
33: * The elements contained within this panel.
34: *
35: * @var PanelElementInterface[]
36: */
37: protected $arrElements;
38:
39: /**
40: * Create a new instance.
41: */
42: public function __construct()
43: {
44: $this->arrElements = array();
45: }
46:
47: /**
48: * {@inheritdoc}
49: */
50: public function getContainer()
51: {
52: return $this->objContainer;
53: }
54:
55: /**
56: * {@inheritdoc}
57: */
58: public function setContainer(PanelContainerInterface $objContainer)
59: {
60: $this->objContainer = $objContainer;
61:
62: return $this;
63: }
64:
65: /**
66: * {@inheritdoc}
67: */
68: public function addElement($strKey, $objElement)
69: {
70: $this->arrElements[$strKey] = $objElement;
71: $objElement->setPanel($this);
72:
73: return $this;
74: }
75:
76: /**
77: * {@inheritdoc}
78: */
79: public function getElement($strKey)
80: {
81: return $this->arrElements[$strKey];
82: }
83:
84: /**
85: * {@inheritdoc}
86: */
87: public function initialize(ConfigInterface $objConfig, PanelElementInterface $objElement = null)
88: {
89: /** @var PanelElementInterface $objThisElement */
90: foreach ($this as $objThisElement)
91: {
92: $objThisElement->initialize($objConfig, $objElement);
93: }
94: }
95:
96: /**
97: * {@inheritdoc}
98: */
99: public function getIterator()
100: {
101: return new \ArrayIterator($this->arrElements);
102: }
103: }
104: