1 | <?php |
||
24 | abstract class FormAbstract implements FormInterface |
||
25 | { |
||
26 | /** |
||
27 | * An instance of Model. |
||
28 | * |
||
29 | * @var Model |
||
30 | */ |
||
31 | protected $model; |
||
32 | |||
33 | /** |
||
34 | * An instance of Current logged user. |
||
35 | * |
||
36 | * @var User |
||
37 | */ |
||
38 | protected $user; |
||
39 | |||
40 | /** |
||
41 | * Set an instance of current logged user. |
||
42 | * |
||
43 | * @param User $user |
||
44 | * |
||
45 | * @return $this |
||
46 | */ |
||
47 | 14 | public function setLoggedUser(User $user) |
|
53 | |||
54 | /** |
||
55 | * Set an instance of model currently being edited. |
||
56 | * |
||
57 | * @param Model $model |
||
58 | * |
||
59 | * @return void|FormInterface |
||
60 | */ |
||
61 | 9 | public function editingModel(Model $model) |
|
67 | |||
68 | /** |
||
69 | * Setup the object from the route parameters. |
||
70 | * |
||
71 | * @param array $params |
||
72 | * |
||
73 | * @return FormInterface |
||
74 | */ |
||
75 | public function setup(array $params) |
||
86 | |||
87 | /** |
||
88 | * Whether or not the form is in editing of a model. |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | 26 | public function isEditing() |
|
96 | |||
97 | /** |
||
98 | * Return an instance of the model being edited. |
||
99 | * |
||
100 | * @return Model |
||
101 | */ |
||
102 | 48 | public function getModel() |
|
106 | |||
107 | /** |
||
108 | * Returns form type. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 39 | public function openType() |
|
116 | |||
117 | /** |
||
118 | * Returns an array of form actions. |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | 14 | public function actions() |
|
126 | |||
127 | /** |
||
128 | * Returns an array of form fields. |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | public function fields() |
||
136 | |||
137 | /** |
||
138 | * Returns an array form rules. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | 15 | public function rules() |
|
146 | |||
147 | /** |
||
148 | * Returns the form redirect url on error. |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getRedirectUrl() |
||
156 | |||
157 | /** |
||
158 | * Returns project upload fields. |
||
159 | * |
||
160 | * @param string $name |
||
161 | * @param Project $project |
||
162 | * @param User $user |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | protected function projectUploadFields($name, Project $project, User $user) |
||
181 | } |
||
182 |
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: