1 | <?php namespace Mascame\Artificer\Fields; |
||
8 | class FieldFactory extends \Mascame\Formality\Factory\Factory |
||
9 | { |
||
10 | |||
11 | public $fieldClass; |
||
12 | public $fields; |
||
13 | public $relatedFields = null; |
||
14 | public $custom_fields = null; |
||
15 | |||
16 | /** |
||
17 | * @var Model |
||
18 | */ |
||
19 | public $modelObject; |
||
20 | public $data; |
||
21 | |||
22 | public $namespace = '\Mascame\Artificer\Fields\Types\\'; |
||
23 | |||
24 | /** |
||
25 | * @param $data |
||
26 | * @return mixed |
||
27 | */ |
||
28 | public function makeFields() |
||
47 | |||
48 | /** |
||
49 | * @param $name |
||
50 | * @return bool|mixed |
||
51 | */ |
||
52 | // protected function getTypeFromConfig($name) { |
||
53 | // if (FieldOption::has('type', $name) || FieldOption::has('relationship.type', $name)) { |
||
54 | // return (FieldOption::has('type', $name)) ? |
||
55 | // FieldOption::get('type', $name) : |
||
56 | // FieldOption::get('relationship.type', $name); |
||
57 | // } |
||
58 | // |
||
59 | // return false; |
||
60 | // } |
||
61 | |||
62 | /** |
||
63 | * @param $name |
||
64 | * @return bool |
||
65 | */ |
||
66 | protected function isRelation($name) |
||
70 | |||
71 | /** |
||
72 | * @return array|null |
||
73 | */ |
||
74 | public function getRelated() |
||
89 | |||
90 | /** |
||
91 | * @return array |
||
92 | */ |
||
93 | protected function withRelated() |
||
105 | |||
106 | /** |
||
107 | * @return array |
||
108 | */ |
||
109 | // protected function withCustomFields() |
||
110 | // { |
||
111 | // if (isset($this->modelObject->options['fields'])) { |
||
112 | // |
||
113 | // foreach ($this->modelObject->options['fields'] as $name => $data) { |
||
114 | // if ( ! in_array($name, $this->modelObject->columns)) { |
||
115 | // $this->modelObject->columns[] = $name; |
||
116 | // } |
||
117 | // } |
||
118 | // |
||
119 | // } |
||
120 | // |
||
121 | // return $this->modelObject->columns; |
||
122 | // } |
||
123 | |||
124 | /** |
||
125 | * @param $field |
||
126 | * @return null |
||
127 | */ |
||
128 | public function fieldValue($field) |
||
132 | |||
133 | } |
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: