@@ 146-164 (lines=19) @@ | ||
143 | * |
|
144 | * @return array |
|
145 | */ |
|
146 | protected function getPostTypeMenu() |
|
147 | { |
|
148 | /* @var $urlBack \yii\web\UrlManager */ |
|
149 | /* @var $postTypes \common\models\PostType[] */ |
|
150 | ||
151 | $urlBack = Yii::$app->urlManagerBack; |
|
152 | $items = []; |
|
153 | $postTypes = PostType::find()->select(['id', 'singular_name', 'permission'])->all(); |
|
154 | ||
155 | foreach ($postTypes as $postType) { |
|
156 | $items[] = [ |
|
157 | 'label' => $postType->singular_name, |
|
158 | 'url' => $urlBack->createUrl(['/post/create', 'type' => $postType->id]), |
|
159 | 'visible' => Yii::$app->user->can($postType->permission), |
|
160 | ]; |
|
161 | } |
|
162 | ||
163 | return $items; |
|
164 | } |
|
165 | ||
166 | /** |
|
167 | * Get dropdown menu for taxonomy. |
|
@@ 171-189 (lines=19) @@ | ||
168 | * |
|
169 | * @return array |
|
170 | */ |
|
171 | protected function getTaxonomyMenu() |
|
172 | { |
|
173 | /* @var $urlBack \yii\web\UrlManager */ |
|
174 | /* @var $taxonomies \common\models\Taxonomy[] */ |
|
175 | ||
176 | $urlBack = Yii::$app->urlManagerBack; |
|
177 | $items = []; |
|
178 | $taxonomies = Taxonomy::find()->select(['id', 'singular_name'])->all(); |
|
179 | ||
180 | foreach ($taxonomies as $taxonomy) { |
|
181 | $items[] = [ |
|
182 | 'label' => $taxonomy->singular_name, |
|
183 | 'url' => $urlBack->createUrl(['/taxonomy/view', 'id' => $taxonomy->id]), |
|
184 | 'visible' => Yii::$app->user->can('editor'), |
|
185 | ]; |
|
186 | } |
|
187 | ||
188 | return $items; |
|
189 | } |
|
190 | ||
191 | /** |
|
192 | * Get dropdown menu for add new. |