1 | <?php |
||
21 | class Generic |
||
22 | { |
||
23 | /** @var string Entity identifier */ |
||
24 | protected static $identifier; |
||
25 | |||
26 | /** @var string Entity navigation identifiers */ |
||
27 | protected static $navigationIDs = array(); |
||
28 | |||
29 | /** @var array Collection of localized additional fields identifiers */ |
||
30 | protected static $localizedFieldIDs = array(); |
||
31 | |||
32 | /** @var array Collection of NOT localized additional fields identifiers */ |
||
33 | protected static $notLocalizedFieldIDs = array(); |
||
34 | |||
35 | /** @var array Collection of all additional fields identifiers */ |
||
36 | protected static $fieldIDs = array(); |
||
37 | |||
38 | /** @var array Collection of all additional fields names */ |
||
39 | protected static $fieldNames = array(); |
||
40 | |||
41 | /** @var @var array Collection of additional fields value column names */ |
||
42 | protected static $fieldValueColumns = array(); |
||
43 | |||
44 | |||
45 | /** @var array Collection selected additional entity fields */ |
||
46 | protected $selectedFields = array(); |
||
47 | |||
48 | /** @var array Collection of entity field filter */ |
||
49 | protected $fieldFilter = array(); |
||
50 | |||
51 | /** @var string Query locale */ |
||
52 | protected $locale = ''; |
||
53 | |||
54 | /** |
||
55 | * Add identifier field query condition. |
||
56 | * |
||
57 | * @param string $value Field value |
||
58 | * @return self Chaining |
||
59 | * @see Generic::where() |
||
60 | */ |
||
61 | public function identifier($value) |
||
65 | |||
66 | /** |
||
67 | * Add entity published field query condition. |
||
68 | * |
||
69 | * @param string $value Field value |
||
70 | * @return self Chaining |
||
71 | * @see Generic::where() |
||
72 | */ |
||
73 | public function published($value) |
||
77 | |||
78 | /** |
||
79 | * Add entity creation field query condition. |
||
80 | * |
||
81 | * @param string $value Field value |
||
82 | * @param string $relation @see ArgumentInterface types |
||
83 | * @return self Chaining |
||
84 | * @see Generic::where() |
||
85 | */ |
||
86 | public function created($value, $relation = ArgumentInterface::EQUAL) |
||
90 | |||
91 | /** |
||
92 | * Add entity modification field query condition. |
||
93 | * |
||
94 | * @param string $value Field value |
||
95 | * @param string $relation @see ArgumentInterface types |
||
96 | * @return self Chaining |
||
97 | * @see Generic::where() |
||
98 | */ |
||
99 | public function modified($value, $relation = ArgumentInterface::EQUAL) |
||
103 | |||
104 | /** |
||
105 | * Select specified entity fields. |
||
106 | * If this method is called then only selected entity fields |
||
107 | * would be return in entity instances. |
||
108 | * |
||
109 | * @param mixed $fieldNames Entity field name or collection of names |
||
110 | * @return self Chaining |
||
111 | */ |
||
112 | public function select($fieldNames) |
||
126 | |||
127 | /** |
||
128 | * Add condition to current query. |
||
129 | * |
||
130 | * @param string $fieldName Entity field name |
||
131 | * @param string $fieldValue Value |
||
132 | * @return self Chaining |
||
133 | */ |
||
134 | public function where($fieldName, $fieldValue = null, $fieldRelation = ArgumentInterface::EQUAL) |
||
145 | |||
146 | /** |
||
147 | * Get collection of entity identifiers filtered by navigation identifiers. |
||
148 | * |
||
149 | * @param array $entityIDs Additional collection of entity identifiers for filtering |
||
150 | * @return array Collection of material identifiers by navigation identifiers |
||
151 | */ |
||
152 | protected function findByNavigationIDs($entityIDs = array()) |
||
156 | |||
157 | /** |
||
158 | * Get collection of entity identifiers filtered by additional field and its value. |
||
159 | * |
||
160 | * @param array $additionalFields Collection of additional field identifiers => values |
||
161 | * @param array $entityIDs Additional collection of entity identifiers for filtering |
||
162 | * @return array Collection of material identifiers by navigation identifiers |
||
163 | */ |
||
164 | protected function findByAdditionalFields($additionalFields, $entityIDs = array()) |
||
179 | |||
180 | /** |
||
181 | * Get entities additional field values. |
||
182 | * |
||
183 | * @param array $entityIDs Collection of entity identifiers |
||
184 | * @return array Collection of entities additional fields EntityID => [Additional field name => Value] |
||
185 | */ |
||
186 | protected function findAdditionalFields($entityIDs) |
||
243 | |||
244 | /** |
||
245 | * Perform SamsonCMS query and get entities collection. |
||
246 | * |
||
247 | * @return mixed[] Collection of found entities |
||
248 | */ |
||
249 | public function find() |
||
284 | |||
285 | /** |
||
286 | * Generic constructor. |
||
287 | * @param string $locale Query localizaation |
||
288 | */ |
||
289 | public function __construct($locale = '') |
||
293 | } |
||
294 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: