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\Palette;
14:
15: use DcGeneral\Data\ModelInterface;
16: use DcGeneral\Data\PropertyValueBag;
17: use DcGeneral\DataDefinition\Palette\Condition\Palette\PaletteConditionInterface;
18: use DcGeneral\Exception\DcGeneralRuntimeException;
19:
20: /**
21: * A palette contains a set of properties, grouped by legends.
22: */
23: interface PaletteInterface
24: {
25: /**
26: * Set the name of this palette.
27: *
28: * @param string $name The name.
29: *
30: * @return PaletteInterface
31: *
32: * @deprecated Only for backwards compatibility, we will remove palette names in the future!
33: */
34: public function setName($name);
35:
36: /**
37: * Return the name of this palette.
38: *
39: * @return string
40: *
41: * @deprecated Only for backwards compatibility, we will remove palette names in the future!
42: */
43: public function getName();
44:
45: /**
46: * Get all properties from all legends in this palette.
47: *
48: * @param ModelInterface|null $model If given, selectors will be evaluated depending on the model.
49: *
50: * @param PropertyValueBag $input If given, selectors will be evaluated depending on the input data.
51: *
52: * @return PropertyInterface[]
53: */
54: public function getProperties(ModelInterface $model = null, PropertyValueBag $input = null);
55:
56:
57: /**
58: * Get all properties from all legends in this palette that are visible.
59: *
60: * @param ModelInterface|null $model If given, selectors will be evaluated depending on the model.
61: *
62: * @param PropertyValueBag $input If given, selectors will be evaluated depending on the input data.
63: *
64: * @return PropertyInterface[]
65: */
66: public function getVisibleProperties(ModelInterface $model = null, PropertyValueBag $input = null);
67:
68: /**
69: * Get all properties from all legends in this palette that are editable.
70: *
71: * @param ModelInterface|null $model If given, selectors will be evaluated depending on the model.
72: *
73: * @param PropertyValueBag $input If given, selectors will be evaluated depending on the input data.
74: *
75: * @return PropertyInterface[]
76: */
77: public function getEditableProperties(ModelInterface $model = null, PropertyValueBag $input = null);
78:
79: /**
80: * Clear all legends from this palette.
81: *
82: * @return PaletteInterface
83: */
84: public function clearLegends();
85:
86: /**
87: * Set all legends to this palette.
88: *
89: * @param array|LegendInterface[] $legends The legends.
90: *
91: * @return PaletteInterface
92: */
93: public function setLegends(array $legends);
94:
95: /**
96: * Add all legends to this palette.
97: *
98: * @param array|LegendInterface[] $legends The legends.
99: *
100: * @param LegendInterface $before The legend before which the new legends shall be inserted (optional).
101: *
102: * @return PaletteInterface
103: */
104: public function addLegends(array $legends, LegendInterface $before = null);
105:
106: /**
107: * Determine if a legend with the given name exists in this palette.
108: *
109: * @param string $name The name of the legend to search for.
110: *
111: * @return bool
112: */
113: public function hasLegend($name);
114:
115: /**
116: * Determine if a legend exists in this palette.
117: *
118: * @param LegendInterface $legend The legend to be checked.
119: *
120: * @return bool
121: */
122: public function containsLegend(LegendInterface $legend);
123:
124: /**
125: * Add a legend to this palette.
126: *
127: * @param LegendInterface $legend The legend to add.
128: *
129: * @param LegendInterface $before The legend before which the new legend shall be inserted (optional).
130: *
131: * @return PaletteInterface
132: */
133: public function addLegend(LegendInterface $legend, LegendInterface $before = null);
134:
135: /**
136: * Remove a legend from this palette.
137: *
138: * @param LegendInterface $legend The legend to remove.
139: *
140: * @return PaletteInterface
141: */
142: public function removeLegend(LegendInterface $legend);
143:
144: /**
145: * Return the legend with the given name.
146: *
147: * @param string $name The name of the legend to search for.
148: *
149: * @return LegendInterface
150: *
151: * @throws DcGeneralRuntimeException Is thrown if there is no legend found.
152: */
153: public function getLegend($name);
154:
155: /**
156: * Return the legends from this palette.
157: *
158: * @return array|LegendInterface[]
159: */
160: public function getLegends();
161:
162: /**
163: * Set the condition bound to this palette.
164: *
165: * @param PaletteConditionInterface|null $condition The condition to be bound to this palette.
166: *
167: * @return PaletteInterface
168: */
169: public function setCondition(PaletteConditionInterface $condition = null);
170:
171: /**
172: * Get the condition bound to this palette.
173: *
174: * @return PaletteConditionInterface|null
175: */
176: public function getCondition();
177:
178: /**
179: * Create a deep clone of the palette.
180: *
181: * @return void
182: */
183: public function __clone();
184: }
185: