1 | <?php |
||
23 | class Project extends FormAbstract |
||
24 | { |
||
25 | /** |
||
26 | * @return array |
||
27 | */ |
||
28 | 4 | public function actions() |
|
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | 4 | public function fields() |
|
52 | { |
||
53 | $fields = [ |
||
54 | 'name' => [ |
||
55 | 'type' => 'text', |
||
56 | 'label' => 'name', |
||
57 | 4 | ], |
|
58 | 'private' => [ |
||
59 | 4 | 'type' => 'select', |
|
60 | 4 | 'label' => 'visibility', |
|
61 | 'options' => [ |
||
62 | 4 | ProjectModel::INTERNAL_YES => trans('tinyissue.internal'), |
|
63 | 4 | ProjectModel::PRIVATE_YES => trans('tinyissue.private'), |
|
64 | 4 | ProjectModel::PRIVATE_NO => trans('tinyissue.public'), |
|
65 | ], |
||
66 | ], |
||
67 | 'default_assignee' => [ |
||
68 | 'type' => 'hidden', |
||
69 | 'id' => 'default_assignee-id', |
||
70 | ], |
||
71 | ]; |
||
72 | |||
73 | // On create project can assign users |
||
74 | // On edit project can change status or default assignee |
||
75 | 4 | if (!$this->isEditing()) { |
|
76 | 1 | $fields['user'] = [ |
|
77 | 1 | 'type' => 'selectUser', |
|
78 | 1 | 'label' => 'assign_users', |
|
79 | 1 | 'id' => 'add-user-project', |
|
80 | 1 | 'placeholder' => trans('tinyissue.assign_a_user'), |
|
81 | ]; |
||
82 | } else { |
||
83 | 3 | $fields['status'] = [ |
|
84 | 3 | 'type' => 'select', |
|
85 | 3 | 'label' => 'status', |
|
86 | 3 | 'options' => [ProjectModel::STATUS_OPEN => trans('tinyissue.open'), ProjectModel::STATUS_ARCHIVED => trans('tinyissue.archived')], |
|
87 | ]; |
||
88 | 3 | $fields['default_assignee'] = [ |
|
89 | 3 | 'type' => 'select', |
|
90 | 3 | 'label' => 'default_assignee', |
|
91 | 3 | 'options' => [0 => ''] + $this->getModel()->usersCanFixIssue()->get()->lists('fullname', 'id')->all(), |
|
92 | ]; |
||
93 | } |
||
94 | |||
95 | 4 | $fields['kanban_board'] = [ |
|
96 | 'type' => 'legend', |
||
97 | ]; |
||
98 | |||
99 | 4 | $fields += $this->getKanbanColumnsField(); |
|
100 | |||
101 | 4 | return $fields; |
|
102 | } |
||
103 | |||
104 | /** |
||
105 | * Return Kanban columns field. |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | 4 | protected function getKanbanColumnsField() |
|
147 | |||
148 | /** |
||
149 | * Returns an array structure for a checkbox button in the kanban field. |
||
150 | * |
||
151 | * @param Tag $tag |
||
152 | * @param bool $checked |
||
153 | * |
||
154 | * @return array |
||
155 | */ |
||
156 | 4 | protected function getKanbanColumnField(Tag $tag, $checked = false) |
|
157 | { |
||
158 | return [ |
||
159 | 4 | 'value' => $tag->id, |
|
160 | 4 | 'data-tags' => $tag->id, |
|
161 | 4 | 'color' => $tag->bgcolor, |
|
162 | 4 | 'checked' => $checked, |
|
163 | ]; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * @return array |
||
168 | */ |
||
169 | 4 | public function rules() |
|
170 | { |
||
171 | $rules = [ |
||
172 | 4 | 'name' => 'required|max:250', |
|
173 | 'user' => 'array|min:1', |
||
174 | ]; |
||
175 | |||
176 | 4 | return $rules; |
|
177 | } |
||
178 | |||
179 | /** |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getRedirectUrl() |
||
190 | } |
||
191 |
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: