1 | <?php |
||
9 | trait AutomatedBehaviorTrait |
||
10 | { |
||
11 | use AutoConstructTrait, AutoMethodsTrait; |
||
12 | |||
13 | /** |
||
14 | * The list of access rights on each property of the object. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | private $_accessProperties; |
||
19 | |||
20 | /** |
||
21 | * The list of collection properties and their item names. |
||
22 | * Ex: [ |
||
23 | * "byItemName" => "user" => ["property" => "users", "behavior" => "list", "methods" => ["add", "remove"]], |
||
24 | * "byProperty" => "users" => ["itemName" => "user", "behavior" => "list", "methods" => ["add", "remove"]] |
||
25 | * ] |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $_collectionsItemNames; |
||
30 | |||
31 | /** |
||
32 | * The list of associations for each property |
||
33 | * Ex: ["products" => ["property" => "cart", "association" => "inverted"]] |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $_associationsList; |
||
38 | |||
39 | /** |
||
40 | * Indicates wether the constraints validation should be enabled or not. |
||
41 | * |
||
42 | * @var boolean |
||
43 | */ |
||
44 | private $_constraintsValidationEnabled = null; |
||
45 | |||
46 | /** |
||
47 | * The initial values of the properties that use Initialize and InitializeObject annotations. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | private $_initialPropertiesValues; |
||
52 | |||
53 | /** |
||
54 | * The arguments needed for the constructor. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | private $_initializationNeededArguments; |
||
59 | |||
60 | /** |
||
61 | * Indicates wether getPropertiesInfo() has been called or not. |
||
62 | * |
||
63 | * @var boolean |
||
64 | */ |
||
65 | private $_automatedBehaviorInitialized = false; |
||
66 | |||
67 | /** |
||
68 | * Indicates if the properties constraints validation is enabled. |
||
69 | * |
||
70 | * @return boolean |
||
71 | */ |
||
72 | public function isPropertiesConstraintsValidationEnabled() |
||
76 | |||
77 | /** |
||
78 | * Enable (or disable) the properties constraints validation. |
||
79 | * |
||
80 | * @param boolean $enabled |
||
81 | */ |
||
82 | 1 | public function setPropertiesConstraintsValidationEnabled($enabled = true) |
|
88 | |||
89 | /** |
||
90 | * Disable (or enable) the properties constraints validation. |
||
91 | * |
||
92 | * @param boolean $disabled |
||
93 | */ |
||
94 | 1 | public function setPropertiesConstraintsValidationDisabled($disabled = true) |
|
100 | |||
101 | /** |
||
102 | * Validates the given value compared to given property constraints. |
||
103 | * If the value is not valid, an InvalidArgumentException will be thrown. |
||
104 | * |
||
105 | * @param string $property The name of the reference property. |
||
106 | * @param mixed $value The value to check. |
||
107 | * |
||
108 | * @throws \InvalidArgumentException If the value is not valid. |
||
109 | */ |
||
110 | 38 | protected function assertPropertyValue($property, $value) |
|
128 | |||
129 | /** |
||
130 | * Update the property associated to the given property. |
||
131 | * You can pass the old or the new value given to the property. |
||
132 | * |
||
133 | * @param string $property The property of the current class to update |
||
134 | * @param object $values An array of old a new value under the following form: |
||
135 | * ['oldValue' => $oldvalue, 'newValue' => $newValue] |
||
136 | * If one of theses values is not given, it will simply not be updated. |
||
137 | */ |
||
138 | 38 | protected function updatePropertyAssociation($property, array $values) |
|
176 | |||
177 | /** |
||
178 | * Get every information needed from this class. |
||
179 | */ |
||
180 | 38 | private function getPropertiesInfo() |
|
198 | } |
||
199 |