1 | <?php |
||
11 | trait AutomatedBehaviorTrait |
||
12 | { |
||
13 | use AutoConstructTrait, AutoMethodsTrait; |
||
14 | |||
15 | /** |
||
16 | * The list of access rights on each property of the object. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | private $_accessProperties; |
||
21 | |||
22 | /** |
||
23 | * The list of collection properties and their item names. |
||
24 | * Ex: [ |
||
25 | * "byItemName" => "user" => ["property" => "users", "behavior" => "list", "methods" => ["add", "remove"]], |
||
26 | * "byProperty" => "users" => ["itemName" => "user", "behavior" => "list", "methods" => ["add", "remove"]] |
||
27 | * ] |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $_collectionsItemNames; |
||
32 | |||
33 | /** |
||
34 | * The list of associations for each property |
||
35 | * Ex: ["products" => ["property" => "cart", "association" => "inverted"]] |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $_associationsList; |
||
40 | |||
41 | /** |
||
42 | * Indicates wether the constraints validation should be enabled or not. |
||
43 | * |
||
44 | * @var boolean |
||
45 | */ |
||
46 | private $_constraintsValidationEnabled; |
||
47 | |||
48 | /** |
||
49 | * Indicates wether getPropertiesInfo() has been called or not. |
||
50 | * |
||
51 | * @var boolean |
||
52 | */ |
||
53 | private $_automatedBehaviorInitialized = false; |
||
54 | |||
55 | /** |
||
56 | * Indicates if the properties constraints validation is enabled. |
||
57 | * |
||
58 | * @return boolean |
||
59 | */ |
||
60 | public function isPropertiesConstraintsValidationEnabled() |
||
64 | |||
65 | /** |
||
66 | * Enable (or disable) the properties constraints validation. |
||
67 | * |
||
68 | * @param boolean $enabled |
||
69 | */ |
||
70 | 1 | public function setPropertiesConstraintsValidationEnabled($enabled = true) |
|
74 | |||
75 | /** |
||
76 | * Disable (or enable) the properties constraints validation. |
||
77 | * |
||
78 | * @param boolean $disabled |
||
79 | */ |
||
80 | 1 | public function setPropertiesConstraintsValidationDisabled($disabled = true) |
|
84 | |||
85 | /** |
||
86 | * Validates the given value compared to given property constraints. |
||
87 | * If the value is not valid, an InvalidArgumentException will be thrown. |
||
88 | * |
||
89 | * @param string $property The name of the reference property. |
||
90 | * @param mixed $value The value to check. |
||
91 | * |
||
92 | * @throws \InvalidArgumentException If the value is not valid. |
||
93 | */ |
||
94 | 29 | protected function assertPropertyValue($property, $value) |
|
112 | |||
113 | /** |
||
114 | * Update the property associated to the given property. |
||
115 | * You can pass the old or the new value given to the property. |
||
116 | * |
||
117 | * @param string $property The property of the current class to update |
||
118 | * @param object $values An array of old a new value under the following form: |
||
119 | * ['oldValue' => $oldvalue, 'newValue' => $newValue] |
||
120 | * If one of theses values is not given, it will simply not be updated. |
||
121 | */ |
||
122 | 29 | protected function updatePropertyAssociation($property, array $values) |
|
164 | |||
165 | /** |
||
166 | * Get every information needed from this class. |
||
167 | */ |
||
168 | 29 | private function getPropertiesInfo() |
|
179 | } |
||
180 |