1 | <?php |
||
20 | class Generic |
||
21 | { |
||
22 | /** @var string Entity identifier */ |
||
23 | protected static $identifier; |
||
24 | |||
25 | /** @var string Entity navigation identifiers */ |
||
26 | protected static $navigationIDs = array(); |
||
27 | |||
28 | /** @var array Collection of localized additional fields identifiers */ |
||
29 | protected static $localizedFieldIDs = array(); |
||
30 | |||
31 | /** @var array Collection of NOT localized additional fields identifiers */ |
||
32 | protected static $notLocalizedFieldIDs = array(); |
||
33 | |||
34 | /** @var array Collection of all additional fields identifiers */ |
||
35 | protected static $fieldIDs = array(); |
||
36 | |||
37 | /** @var array Collection of all additional fields names */ |
||
38 | protected static $fieldNames = array(); |
||
39 | |||
40 | /** @var @var array Collection of additional fields value column names */ |
||
41 | protected static $fieldValueColumns = array(); |
||
42 | |||
43 | |||
44 | /** @var array Collection selected additional entity fields */ |
||
45 | protected $selectedFields = array(); |
||
46 | |||
47 | /** @var array Collection of entity field filter */ |
||
48 | protected $fieldFilter = array(); |
||
49 | |||
50 | /** @var string Query locale */ |
||
51 | protected $locale = ''; |
||
52 | |||
53 | /** |
||
54 | * Select specified entity fields. |
||
55 | * If this method is called then only selected entity fields |
||
56 | * would be return in entity instances. |
||
57 | * |
||
58 | * @param mixed $fieldNames Entity field name or collection of names |
||
59 | * @return self Chaining |
||
60 | */ |
||
61 | public function select($fieldNames) |
||
75 | |||
76 | /** |
||
77 | * Add condition to current query. |
||
78 | * |
||
79 | * @param string $fieldName Entity field name |
||
80 | * @param string $fieldValue Value |
||
81 | * @return self Chaining |
||
82 | */ |
||
83 | public function where($fieldName, $fieldValue = null) |
||
94 | |||
95 | /** |
||
96 | * Get collection of entity identifiers filtered by navigation identifiers. |
||
97 | * |
||
98 | * @param array $entityIDs Additional collection of entity identifiers for filtering |
||
99 | * @return array Collection of material identifiers by navigation identifiers |
||
100 | */ |
||
101 | protected function findByNavigationIDs($entityIDs = array()) |
||
105 | |||
106 | /** |
||
107 | * Get collection of entity identifiers filtered by additional field and its value. |
||
108 | * |
||
109 | * @param array $additionalFields Collection of additional field identifiers => values |
||
110 | * @param array $entityIDs Additional collection of entity identifiers for filtering |
||
111 | * @return array Collection of material identifiers by navigation identifiers |
||
112 | */ |
||
113 | protected function findByAdditionalFields($additionalFields, $entityIDs = array()) |
||
128 | |||
129 | /** |
||
130 | * Get entities additional field values. |
||
131 | * |
||
132 | * @param array $entityIDs Collection of entity identifiers |
||
133 | * @return array Collection of entities additional fields EntityID => [Additional field name => Value] |
||
134 | */ |
||
135 | protected function findAdditionalFields($entityIDs) |
||
192 | |||
193 | /** |
||
194 | * Perform SamsonCMS query and get entities collection. |
||
195 | * |
||
196 | * @return mixed[] Collection of found entities |
||
197 | */ |
||
198 | public function find() |
||
230 | |||
231 | /** |
||
232 | * Generic constructor. |
||
233 | * @param string $locale Query localizaation |
||
234 | */ |
||
235 | public function __construct($locale = '') |
||
239 | } |
||
240 |
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: