itstructure /
yii2-template-simple
| 1 | <?php |
||
| 2 | |||
| 3 | namespace app\controllers\admin; |
||
| 4 | |||
| 5 | use app\traits\{AdminBeforeActionTrait, AccessTrait}; |
||
| 6 | use app\models\{About, Technology, TechnologySearch}; |
||
| 7 | use Itstructure\AdminModule\controllers\CommonAdminController; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class TechnologyController |
||
| 11 | * TechnologyController implements the CRUD actions for Technology model. |
||
| 12 | * |
||
| 13 | * @package app\controllers\admin |
||
| 14 | */ |
||
| 15 | class TechnologyController extends CommonAdminController |
||
| 16 | { |
||
| 17 | use AdminBeforeActionTrait, AccessTrait; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 18 | |||
| 19 | /** |
||
| 20 | * @var bool |
||
| 21 | */ |
||
| 22 | protected $setEditingScenarios = true; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @return mixed|string |
||
| 26 | */ |
||
| 27 | public function actionIndex() |
||
| 28 | { |
||
| 29 | if (!$this->checkAccessToIndex()) { |
||
| 30 | return $this->accessError(); |
||
| 31 | } |
||
| 32 | |||
| 33 | return parent::actionIndex(); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param int|string $id |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | public function actionView($id) |
||
| 42 | { |
||
| 43 | if (!$this->checkAccessToView()) { |
||
| 44 | return $this->accessError(); |
||
| 45 | } |
||
| 46 | |||
| 47 | return parent::actionView($id); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return mixed|string|\yii\web\Response |
||
| 52 | */ |
||
| 53 | public function actionCreate() |
||
| 54 | { |
||
| 55 | if (!$this->checkAccessToCreate()) { |
||
| 56 | return $this->accessError(); |
||
| 57 | } |
||
| 58 | |||
| 59 | return parent::actionCreate(); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param int|string $id |
||
| 64 | * |
||
| 65 | * @return string|\yii\web\Response |
||
| 66 | */ |
||
| 67 | public function actionUpdate($id) |
||
| 68 | { |
||
| 69 | if (!$this->checkAccessToUpdate()) { |
||
| 70 | return $this->accessError(); |
||
| 71 | } |
||
| 72 | |||
| 73 | return parent::actionUpdate($id); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param int|string $id |
||
| 78 | * |
||
| 79 | * @return mixed|\yii\web\Response |
||
| 80 | */ |
||
| 81 | public function actionDelete($id) |
||
| 82 | { |
||
| 83 | if (!$this->checkAccessToDelete()) { |
||
| 84 | return $this->accessError(); |
||
| 85 | } |
||
| 86 | |||
| 87 | return parent::actionDelete($id); |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Get addition fields for the view template. |
||
| 92 | * |
||
| 93 | * @return array |
||
| 94 | */ |
||
| 95 | protected function getAdditionFields(): array |
||
| 96 | { |
||
| 97 | if ($this->action->id == 'create' || $this->action->id == 'update') { |
||
| 98 | return [ |
||
| 99 | 'aboutList' => About::find()->all(), |
||
| 100 | ]; |
||
| 101 | } |
||
| 102 | |||
| 103 | return $this->additionFields; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Returns Technology model name. |
||
| 108 | * |
||
| 109 | * @return string |
||
| 110 | */ |
||
| 111 | protected function getModelName():string |
||
| 112 | { |
||
| 113 | return Technology::class; |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Returns TechnologySearch model name. |
||
| 118 | * |
||
| 119 | * @return string |
||
| 120 | */ |
||
| 121 | protected function getSearchModelName():string |
||
| 122 | { |
||
| 123 | return TechnologySearch::class; |
||
| 124 | } |
||
| 125 | } |
||
| 126 |