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\View;
14:
15: use DcGeneral\Exception\DcGeneralInvalidArgumentException;
16:
17: /**
18: * Class DefaultListingConfig.
19: *
20: * Default implementation of a listing config.
21: *
22: * @package DcGeneral\DataDefinition\Definition\View
23: */
24: class DefaultListingConfig implements ListingConfigInterface
25: {
26: /**
27: * The grouping mode to use.
28: *
29: * @var string
30: */
31: protected $groupingMode;
32:
33: /**
34: * The grouing length to use.
35: *
36: * @var string
37: */
38: protected $groupingLength;
39:
40: /**
41: * The default sorting mode.
42: *
43: * @var string
44: */
45: protected $sortingMode;
46:
47: /**
48: * The names of the properties that will be used for sorting by default.
49: *
50: * @var array
51: */
52: protected $defaultSortingFields;
53:
54: /**
55: * The properties to display in the heder (parented mode only).
56: *
57: * @var array
58: */
59: protected $headerProperties;
60:
61: /**
62: * The root icon to use (hierarchical mode only).
63: *
64: * @var string
65: */
66: protected $rootIcon;
67:
68: /**
69: * The CSS class to apply to each item in the listing.
70: *
71: * @var string
72: */
73: protected $itemCssClass;
74:
75: /**
76: * The item formatter to use.
77: *
78: * @var DefaultModelFormatterConfig[]
79: */
80: protected $itemFormatter;
81:
82: /**
83: * Flag if the properties displayed shall be shown as table layout.
84: *
85: * @var bool
86: */
87: protected $showColumns;
88:
89: /**
90: * {@inheritdoc}
91: */
92: public function setGroupingMode($value)
93: {
94: $this->groupingMode = $value;
95:
96: return $this;
97: }
98:
99: /**
100: * {@inheritdoc}
101: */
102: public function getGroupingMode()
103: {
104: return $this->groupingMode;
105: }
106:
107: /**
108: * {@inheritdoc}
109: */
110: public function setGroupingLength($value)
111: {
112: $this->groupingLength = $value;
113:
114: return $this;
115: }
116:
117: /**
118: * {@inheritdoc}
119: */
120: public function getGroupingLength()
121: {
122: return $this->groupingLength;
123: }
124:
125: /**
126: * {@inheritdoc}
127: */
128: public function setSortingMode($value)
129: {
130: $this->sortingMode = $value;
131:
132: return $this;
133: }
134:
135: /**
136: * {@inheritdoc}
137: */
138: public function getSortingMode()
139: {
140: return $this->sortingMode;
141: }
142:
143: /**
144: * {@inheritdoc}
145: */
146: public function setDefaultSortingFields($value)
147: {
148: $this->defaultSortingFields = $value;
149:
150: return $this;
151: }
152:
153: /**
154: * {@inheritdoc}
155: */
156: public function getDefaultSortingFields()
157: {
158: return $this->defaultSortingFields;
159: }
160:
161: /**
162: * {@inheritdoc}
163: */
164: public function setHeaderPropertyNames($value)
165: {
166: $this->headerProperties = $value;
167:
168: return $this;
169: }
170:
171: /**
172: * {@inheritdoc}
173: */
174: public function getHeaderPropertyNames()
175: {
176: return $this->headerProperties;
177: }
178:
179: /**
180: * {@inheritdoc}
181: */
182: public function setRootIcon($value)
183: {
184: $this->rootIcon = $value;
185:
186: return $this;
187: }
188:
189: /**
190: * {@inheritdoc}
191: */
192: public function getRootIcon()
193: {
194: return $this->rootIcon;
195: }
196:
197: /**
198: * {@inheritdoc}
199: */
200: public function setItemCssClass($value)
201: {
202: $this->itemCssClass = $value;
203:
204: return $this;
205: }
206:
207: /**
208: * {@inheritdoc}
209: */
210: public function getItemCssClass()
211: {
212: return $this->itemCssClass;
213: }
214:
215: /**
216: * {@inheritdoc}
217: */
218: public function setLabelFormatter($providerName, $value)
219: {
220: $this->itemFormatter[$providerName] = $value;
221:
222: return $this;
223: }
224:
225: /**
226: * {@inheritdoc}
227: */
228: public function hasLabelFormatter($providerName)
229: {
230: return isset($this->itemFormatter[$providerName]);
231: }
232:
233: /**
234: * {@inheritdoc}
235: *
236: * @throws DcGeneralInvalidArgumentException When no formatter has been defined.
237: */
238: public function getLabelFormatter($providerName)
239: {
240: if (!isset($this->itemFormatter[$providerName]))
241: {
242: throw new DcGeneralInvalidArgumentException(
243: 'Formatter configuration for data provider ' . $providerName . ' is not registered.'
244: );
245: }
246:
247: return $this->itemFormatter[$providerName];
248: }
249:
250: /**
251: * {@inheritdoc}
252: */
253: public function setShowColumns($value)
254: {
255: $this->showColumns = $value;
256:
257: return $this;
258: }
259:
260: /**
261: * {@inheritdoc}
262: */
263: public function getShowColumns()
264: {
265: return $this->showColumns;
266: }
267: }
268: