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 @var array Collection of additional fields value column names */ |
||
39 | protected static $fieldValueColumns = array(); |
||
40 | |||
41 | |||
42 | /** @var array Collection of entity field filter */ |
||
43 | protected $fieldFilter = array(); |
||
44 | |||
45 | /** @var string Query locale */ |
||
46 | protected $locale = ''; |
||
47 | |||
48 | /** |
||
49 | * Add condition to current query. |
||
50 | * |
||
51 | * @param string $fieldName Entity field name |
||
52 | * @param string $fieldValue Value |
||
53 | * @return self Chaining |
||
54 | */ |
||
55 | public function where($fieldName, $fieldValue = null) |
||
65 | |||
66 | /** |
||
67 | * Get collection of entity identifiers filtered by navigation identifiers. |
||
68 | * |
||
69 | * @param array $entityIDs Additional collection of entity identifiers for filtering |
||
70 | * @return array Collection of material identifiers by navigation identifiers |
||
71 | */ |
||
72 | protected function findByNavigationIDs($entityIDs = array()) |
||
76 | |||
77 | /** |
||
78 | * Get collection of entity identifiers filtered by additional field and its value. |
||
79 | * |
||
80 | * @param array $additionalFields Collection of additional field identifiers => values |
||
81 | * @param array $entityIDs Additional collection of entity identifiers for filtering |
||
82 | * @return array Collection of material identifiers by navigation identifiers |
||
83 | */ |
||
84 | protected function findByAdditionalFields($additionalFields, $entityIDs = array()) |
||
99 | |||
100 | protected function findAdditionalFields($entityIDs) |
||
138 | |||
139 | /** |
||
140 | * Perform SamsonCMS query and get entities collection. |
||
141 | * |
||
142 | * @return mixed[] Collection of found entities |
||
143 | */ |
||
144 | public function find() |
||
170 | |||
171 | /** |
||
172 | * Generic constructor. |
||
173 | * @param string $locale Query localizaation |
||
174 | */ |
||
175 | public function __construct($locale = '') |
||
179 | } |
||
180 |
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: