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