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: use DcGeneral\EnvironmentInterface;
17: use DcGeneral\InputProviderInterface;
18:
19: /**
20: * Abstract base implementation for panel elements.
21: *
22: * @package DcGeneral\Panel
23: */
24: abstract class AbstractElement
25: implements PanelElementInterface
26: {
27: /**
28: * The panel this element is contained within.
29: *
30: * @var PanelInterface
31: */
32: protected $objPanel;
33:
34: /**
35: * The base configuration that contains all filter, sorting and limit information for all other panel elements.
36: *
37: * This is used for determining the valid values in filters etc.
38: *
39: * @var \DcGeneral\Data\ConfigInterface
40: */
41: private $objOtherConfig;
42:
43: /**
44: * Convenience method to retrieve Environment for this element.
45: *
46: * @return EnvironmentInterface
47: */
48: public function getEnvironment()
49: {
50: return $this->getPanel()->getContainer()->getEnvironment();
51: }
52:
53: /**
54: * Convenience method to retrieve input provider for this Element.
55: *
56: * @return InputProviderInterface
57: */
58: public function getInputProvider()
59: {
60: return $this->getEnvironment()->getInputProvider();
61: }
62:
63: /**
64: * {@inheritDoc}
65: */
66: public function getPanel()
67: {
68: return $this->objPanel;
69: }
70:
71: /**
72: * {@inheritDoc}
73: */
74: public function setPanel(PanelInterface $objPanel)
75: {
76: $this->objPanel = $objPanel;
77:
78: return $this;
79: }
80:
81: /**
82: * Let all other elements initialize and apply themselves to this config.
83: *
84: * @return ConfigInterface
85: */
86: protected function getOtherConfig()
87: {
88: if (!isset($this->objOtherConfig))
89: {
90: $this->objOtherConfig = $this
91: ->getEnvironment()
92: ->getController()
93: ->getBaseConfig();
94:
95: $this
96: ->getPanel()
97: ->getContainer()
98: ->initialize($this->objOtherConfig, $this);
99: }
100:
101: return $this->objOtherConfig;
102: }
103: }
104: