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\DataDefinition\Definition;
14:
15: /**
16: * Default implementation of the basic information about the data definition.
17: *
18: * @package DcGeneral\DataDefinition\Definition
19: */
20: class DefaultBasicDefinition implements BasicDefinitionInterface
21: {
22: /**
23: * The mode.
24: *
25: * @var int
26: */
27: protected $mode;
28:
29: /**
30: * The name of the data provider of the root elements.
31: *
32: * @var string
33: */
34: protected $rootProviderName;
35:
36: /**
37: * The name of the data provider of the parent element.
38: *
39: * @var string
40: */
41: protected $parentProviderName;
42:
43: /**
44: * The name of the data provider of the elements being processed.
45: *
46: * @var string
47: */
48: protected $providerName;
49:
50: /**
51: * Array of filter rules.
52: *
53: * @var array
54: */
55: protected $additionalFilter;
56:
57: /**
58: * If true, adding of further records is prohibited.
59: *
60: * @var bool
61: */
62: protected $isClosed = false;
63:
64: /**
65: * Boolean flag determining if this data container is editable.
66: *
67: * @var bool
68: */
69: protected $isEditable = true;
70:
71: /**
72: * Boolean flag determining if this data container is deletable.
73: *
74: * @var bool
75: */
76: protected $isDeletable = true;
77:
78: /**
79: * Determines if new entries may be created within this data container.
80: *
81: * @var bool
82: */
83: protected $isCreatable = true;
84:
85: /**
86: * Determines if the view shall switch automatically into edit mode.
87: *
88: * @var bool
89: */
90: protected $switchToEditEnabled;
91:
92: /**
93: * {@inheritdoc}
94: */
95: public function setMode($mode)
96: {
97: $this->mode = $mode;
98:
99: return $this;
100: }
101:
102: /**
103: * {@inheritdoc}
104: */
105: public function getMode()
106: {
107: return $this->mode;
108: }
109:
110: /**
111: * {@inheritdoc}
112: */
113: public function setRootDataProvider($providerName)
114: {
115: $this->rootProviderName = $providerName;
116:
117: return $this;
118: }
119:
120: /**
121: * {@inheritdoc}
122: */
123: public function getRootDataProvider()
124: {
125: return $this->rootProviderName;
126: }
127:
128: /**
129: * {@inheritdoc}
130: */
131: public function setParentDataProvider($providerName)
132: {
133: $this->parentProviderName = $providerName;
134:
135: return $this;
136: }
137:
138: /**
139: * {@inheritdoc}
140: */
141: public function getParentDataProvider()
142: {
143: return $this->parentProviderName;
144: }
145:
146: /**
147: * {@inheritdoc}
148: */
149: public function setDataProvider($providerName)
150: {
151: $this->providerName = $providerName;
152:
153: return $this;
154: }
155:
156: /**
157: * {@inheritdoc}
158: */
159: public function getDataProvider()
160: {
161: return $this->providerName;
162: }
163:
164: /**
165: * {@inheritdoc}
166: */
167: public function setAdditionalFilter($dataProvider, $filter)
168: {
169: $this->additionalFilter[$dataProvider] = $filter;
170:
171: return $this;
172: }
173:
174: /**
175: * {@inheritdoc}
176: */
177: public function hasAdditionalFilter($dataProvider = null)
178: {
179: if ($dataProvider === null)
180: {
181: $dataProvider = $this->getDataProvider();
182: }
183:
184: return isset($this->additionalFilter[$dataProvider]);
185: }
186:
187: /**
188: * {@inheritdoc}
189: */
190: public function getAdditionalFilter($dataProvider = null)
191: {
192: if ($dataProvider === null)
193: {
194: $dataProvider = $this->getDataProvider();
195: }
196:
197: return $this->additionalFilter[$dataProvider];
198: }
199:
200: /**
201: * {@inheritdoc}
202: */
203: public function setClosed($value)
204: {
205: $this->isClosed = $value;
206:
207: return $this;
208: }
209:
210: /**
211: * {@inheritdoc}
212: */
213: public function isClosed()
214: {
215: return $this->isClosed;
216: }
217:
218: /**
219: * {@inheritdoc}
220: */
221: public function setEditable($value)
222: {
223: $this->isEditable = $value;
224:
225: return $this;
226: }
227:
228: /**
229: * {@inheritdoc}
230: */
231: public function isEditable()
232: {
233: return $this->isEditable;
234: }
235:
236: /**
237: * {@inheritdoc}
238: */
239: public function setDeletable($value)
240: {
241: $this->isDeletable = $value;
242:
243: return $this;
244: }
245:
246: /**
247: * {@inheritdoc}
248: */
249: public function isDeletable()
250: {
251: return $this->isDeletable;
252: }
253:
254: /**
255: * {@inheritdoc}
256: */
257: public function setCreatable($value)
258: {
259: $this->isCreatable = $value;
260:
261: return $this;
262: }
263:
264: /**
265: * {@inheritdoc}
266: */
267: public function isCreatable()
268: {
269: return $this->isCreatable;
270: }
271:
272:
273: /**
274: * {@inheritdoc}
275: */
276: public function setSwitchToEditEnabled($switchToEditEnabled)
277: {
278: $this->switchToEditEnabled = $switchToEditEnabled;
279:
280: return $this;
281: }
282:
283: /**
284: * {@inheritdoc}
285: */
286: public function isSwitchToEditEnabled()
287: {
288: return $this->switchToEditEnabled;
289: }
290: }
291: