1 | <?php |
||
23 | class Project extends FormAbstract |
||
24 | { |
||
25 | /** |
||
26 | * @return array |
||
27 | */ |
||
28 | 3 | public function actions() |
|
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | 3 | public function fields() |
|
99 | |||
100 | /** |
||
101 | * Return Kanban columns field. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 3 | protected function getKanbanColumnsField() |
|
106 | { |
||
107 | 3 | $fields = []; |
|
108 | |||
109 | // All of the status tags |
||
110 | 3 | $statusTags = (new Tag())->getStatusTags()->get()->filter(function (TagModel $tag) { |
|
111 | 3 | return !($tag->name == TagModel::STATUS_OPEN || $tag->name == TagModel::STATUS_CLOSED); |
|
112 | 3 | }); |
|
113 | |||
114 | // Get selected status tags on editing a project |
||
115 | 3 | $selectTags = []; |
|
116 | 3 | if ($this->isEditing()) { |
|
117 | 2 | $selectTags = $this->getModel()->kanbanTags()->get()->lists('id'); |
|
118 | } |
||
119 | |||
120 | // An array for checkboxes |
||
121 | 3 | $options = []; |
|
122 | 3 | foreach ($selectTags as $tagId) { |
|
123 | $tag = $statusTags->find($tagId); |
||
124 | if ($tag) { |
||
125 | $options[ucwords($tag->name)] = $this->getKanbanColumnField($tag, true); |
||
126 | } |
||
127 | } |
||
128 | |||
129 | 3 | foreach ($statusTags as $tag) { |
|
130 | 3 | if (!isset($options[ucwords($tag->name)])) { |
|
131 | 3 | $options[ucwords($tag->name)] = $this->getKanbanColumnField($tag); |
|
132 | } |
||
133 | } |
||
134 | |||
135 | // The checkbox button element |
||
136 | 3 | $fields['columns[]'] = [ |
|
137 | 3 | 'label' => 'columns', |
|
138 | 3 | 'type' => 'checkboxButton', |
|
139 | 3 | 'checkboxes' => $options, |
|
140 | 'grouped' => true, |
||
141 | ]; |
||
142 | |||
143 | 3 | return $fields; |
|
144 | } |
||
145 | |||
146 | /** |
||
147 | * Returns an array structure for a checkbox button in the kanban field. |
||
148 | * |
||
149 | * @param Tag $tag |
||
150 | * @param bool $checked |
||
151 | * |
||
152 | * @return array |
||
153 | */ |
||
154 | 3 | protected function getKanbanColumnField(Tag $tag, $checked = false) |
|
163 | |||
164 | /** |
||
165 | * @return array |
||
166 | */ |
||
167 | 3 | public function rules() |
|
176 | |||
177 | /** |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getRedirectUrl() |
||
188 | } |
||
189 |
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: