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\ModelRelationship;
14:
15: use DcGeneral\Data\ModelInterface;
16:
17: /**
18: * This interface holds the information how a parent model relates to a child model.
19: *
20: * @package DcGeneral\DataDefinition\ModelRelationship
21: */
22: interface ParentChildConditionInterface
23: {
24: /**
25: * Set the condition as filter.
26: *
27: * @param array $value The filter rules describing the relationship.
28: *
29: * @return ParentChildConditionInterface
30: */
31: public function setFilterArray($value);
32:
33: /**
34: * Get the condition as filter.
35: *
36: * @return array
37: */
38: public function getFilterArray();
39:
40: /**
41: * Set the condition setters.
42: *
43: * @param array $value The values to be applied to a model when it shall get set as child of another one.
44: *
45: * @return ParentChildConditionInterface
46: */
47: public function setSetters($value);
48:
49: /**
50: * Get the condition setters.
51: *
52: * @return array
53: */
54: public function getSetters();
55:
56: /**
57: * Set the inverse filter for the condition.
58: *
59: * @param array $value The filter rules to use when inverting the condition to look up the parent.
60: *
61: * @return ParentChildConditionInterface
62: */
63: public function setInverseFilterArray($value);
64:
65: /**
66: * Get the inverse filter for the condition.
67: *
68: * @return array
69: */
70: public function getInverseFilterArray();
71:
72: /**
73: * Get the condition as filter related to the given model.
74: *
75: * @param ModelInterface $objParent The model that shall get used as parent.
76: *
77: * @return array
78: */
79: public function getFilter($objParent);
80:
81: /**
82: * Set the name of the source provider.
83: *
84: * @param string $value The name of the provider.
85: *
86: * @return ParentChildConditionInterface
87: */
88: public function setSourceName($value);
89:
90: /**
91: * Return the name of the source provider (parent).
92: *
93: * @return string
94: */
95: public function getSourceName();
96:
97: /**
98: * Set the name of the destination provider (child).
99: *
100: * @param string $value The name of the provider.
101: *
102: * @return ParentChildConditionInterface
103: */
104: public function setDestinationName($value);
105:
106: /**
107: * Return the name of the destination provider.
108: *
109: * @return string
110: */
111: public function getDestinationName();
112:
113: /**
114: * Apply a condition to a child.
115: *
116: * @param ModelInterface $objParent The parent object.
117: *
118: * @param ModelInterface $objChild The object on which the condition shall be enforced on.
119: *
120: * @return void
121: */
122: public function applyTo($objParent, $objChild);
123:
124: /**
125: * Apply a condition to a child by copying it from another child.
126: *
127: * @param ModelInterface $sourceModel The sibling model.
128: *
129: * @param ModelInterface $destinationModel The model on which the condition shall be enforced on.
130: *
131: * @return void
132: */
133: public function copyFrom($sourceModel, $destinationModel);
134:
135: /**
136: * Get the inverted condition as filter.
137: *
138: * This allows to look up the parent of a child model.
139: *
140: * @param ModelInterface $objChild The model that shall get used as child and for which the parent filter shall get
141: * retrieved.
142: *
143: * @return array|null
144: */
145: public function getInverseFilterFor($objChild);
146:
147: /**
148: * Test if the given parent is indeed a parent of the given child object for this condition.
149: *
150: * @param ModelInterface $objParent The parent model.
151: *
152: * @param ModelInterface $objChild The child model.
153: *
154: * @return bool
155: */
156: public function matches($objParent, $objChild);
157: }
158: