Code Duplication    Length = 104-104 lines in 3 locations

controllers/admin/ArticleController.php 1 location

@@ 16-119 (lines=104) @@
13
 *
14
 * @package app\controllers\admin
15
 */
16
class ArticleController extends CommonAdminController
17
{
18
    use AdminBeforeActionTrait, AccessTrait, AdditionFieldsTrait;
19
20
    /**
21
     * @var bool
22
     */
23
    protected $setEditingScenarios = true;
24
25
    /**
26
     * @return mixed|string
27
     */
28
    public function actionIndex()
29
    {
30
        if (!$this->checkAccessToIndex()) {
31
            return $this->accessError();
32
        }
33
34
        return parent::actionIndex();
35
    }
36
37
    /**
38
     * @param int|string $id
39
     *
40
     * @return mixed
41
     */
42
    public function actionView($id)
43
    {
44
        if (!$this->checkAccessToView()) {
45
            return $this->accessError();
46
        }
47
48
        $this->additionFields['images'] = $this->getMediaFiles(Article::tableName(), (int)$id, UploadModelInterface::FILE_TYPE_IMAGE);
49
50
        return parent::actionView($id);
51
    }
52
53
    /**
54
     * @return mixed|string|\yii\web\Response
55
     */
56
    public function actionCreate()
57
    {
58
        if (!$this->checkAccessToCreate()) {
59
            return $this->accessError();
60
        }
61
62
        $this->additionFields['pages'] = Page::getMenu();
63
        $this->additionFields['albums'] = $this->getAlbums();
64
65
        return parent::actionCreate();
66
    }
67
68
    /**
69
     * @param int|string $id
70
     *
71
     * @return string|\yii\web\Response
72
     */
73
    public function actionUpdate($id)
74
    {
75
        if (!$this->checkAccessToUpdate()) {
76
            return $this->accessError();
77
        }
78
79
        $this->additionFields['pages'] = Page::getMenu();
80
        $this->additionFields['albums'] = $this->getAlbums();
81
        $this->additionFields['images'] = $this->getMediaFiles(Article::tableName(), (int)$id, UploadModelInterface::FILE_TYPE_IMAGE);
82
83
        return parent::actionUpdate($id);
84
    }
85
86
    /**
87
     * @param int|string $id
88
     *
89
     * @return mixed|\yii\web\Response
90
     */
91
    public function actionDelete($id)
92
    {
93
        if (!$this->checkAccessToDelete()) {
94
            return $this->accessError();
95
        }
96
97
        return parent::actionDelete($id);
98
    }
99
100
    /**
101
     * Returns Product model name.
102
     *
103
     * @return string
104
     */
105
    protected function getModelName():string
106
    {
107
        return Article::class;
108
    }
109
110
    /**
111
     * Returns ProductSearch model name.
112
     *
113
     * @return string
114
     */
115
    protected function getSearchModelName():string
116
    {
117
        return ArticleSearch::class;
118
    }
119
}
120

controllers/admin/PageController.php 1 location

@@ 16-119 (lines=104) @@
13
 *
14
 * @package app\controllers\admin
15
 */
16
class PageController extends CommonAdminController
17
{
18
    use AdminBeforeActionTrait, AccessTrait, AdditionFieldsTrait;
19
20
    /**
21
     * @var bool
22
     */
23
    protected $setEditingScenarios = true;
24
25
    /**
26
     * @return mixed|string
27
     */
28
    public function actionIndex()
29
    {
30
        if (!$this->checkAccessToIndex()) {
31
            return $this->accessError();
32
        }
33
34
        return parent::actionIndex();
35
    }
36
37
    /**
38
     * @param int|string $id
39
     *
40
     * @return mixed
41
     */
42
    public function actionView($id)
43
    {
44
        if (!$this->checkAccessToView()) {
45
            return $this->accessError();
46
        }
47
48
        $this->additionFields['images'] = $this->getMediaFiles(Page::tableName(), (int)$id, UploadModelInterface::FILE_TYPE_IMAGE);
49
50
        return parent::actionView($id);
51
    }
52
53
    /**
54
     * @return mixed|string|\yii\web\Response
55
     */
56
    public function actionCreate()
57
    {
58
        if (!$this->checkAccessToCreate()) {
59
            return $this->accessError();
60
        }
61
62
        $this->additionFields['pages'] = Page::getMenu();
63
        $this->additionFields['albums'] = $this->getAlbums();
64
65
        return parent::actionCreate();
66
    }
67
68
    /**
69
     * @param int|string $id
70
     *
71
     * @return string|\yii\web\Response
72
     */
73
    public function actionUpdate($id)
74
    {
75
        if (!$this->checkAccessToUpdate()) {
76
            return $this->accessError();
77
        }
78
79
        $this->additionFields['pages'] = Page::getMenu();
80
        $this->additionFields['albums'] = $this->getAlbums();
81
        $this->additionFields['images'] = $this->getMediaFiles(Page::tableName(), (int)$id, UploadModelInterface::FILE_TYPE_IMAGE);
82
83
        return parent::actionUpdate($id);
84
    }
85
86
    /**
87
     * @param int|string $id
88
     *
89
     * @return mixed|\yii\web\Response
90
     */
91
    public function actionDelete($id)
92
    {
93
        if (!$this->checkAccessToDelete()) {
94
            return $this->accessError();
95
        }
96
97
        return parent::actionDelete($id);
98
    }
99
100
    /**
101
     * Returns Page model name.
102
     *
103
     * @return string
104
     */
105
    protected function getModelName():string
106
    {
107
        return Page::class;
108
    }
109
110
    /**
111
     * Returns PageSearch model name.
112
     *
113
     * @return string
114
     */
115
    protected function getSearchModelName():string
116
    {
117
        return PageSearch::class;
118
    }
119
}
120

controllers/admin/ProductController.php 1 location

@@ 16-119 (lines=104) @@
13
 *
14
 * @package app\controllers\admin
15
 */
16
class ProductController extends CommonAdminController
17
{
18
    use AdminBeforeActionTrait, AccessTrait, AdditionFieldsTrait;
19
20
    /**
21
     * @var bool
22
     */
23
    protected $setEditingScenarios = true;
24
25
    /**
26
     * @return mixed|string
27
     */
28
    public function actionIndex()
29
    {
30
        if (!$this->checkAccessToIndex()) {
31
            return $this->accessError();
32
        }
33
34
        return parent::actionIndex();
35
    }
36
37
    /**
38
     * @param int|string $id
39
     *
40
     * @return mixed
41
     */
42
    public function actionView($id)
43
    {
44
        if (!$this->checkAccessToView()) {
45
            return $this->accessError();
46
        }
47
48
        $this->additionFields['images'] = $this->getMediaFiles(Product::tableName(), (int)$id, UploadModelInterface::FILE_TYPE_IMAGE);
49
50
        return parent::actionView($id);
51
    }
52
53
    /**
54
     * @return mixed|string|\yii\web\Response
55
     */
56
    public function actionCreate()
57
    {
58
        if (!$this->checkAccessToCreate()) {
59
            return $this->accessError();
60
        }
61
62
        $this->additionFields['categories'] = Category::getMenu();
63
        $this->additionFields['albums'] = $this->getAlbums();
64
65
        return parent::actionCreate();
66
    }
67
68
    /**
69
     * @param int|string $id
70
     *
71
     * @return string|\yii\web\Response
72
     */
73
    public function actionUpdate($id)
74
    {
75
        if (!$this->checkAccessToUpdate()) {
76
            return $this->accessError();
77
        }
78
79
        $this->additionFields['categories'] = Category::getMenu();
80
        $this->additionFields['albums'] = $this->getAlbums();
81
        $this->additionFields['images'] = $this->getMediaFiles(Product::tableName(), (int)$id, UploadModelInterface::FILE_TYPE_IMAGE);
82
83
        return parent::actionUpdate($id);
84
    }
85
86
    /**
87
     * @param int|string $id
88
     *
89
     * @return mixed|\yii\web\Response
90
     */
91
    public function actionDelete($id)
92
    {
93
        if (!$this->checkAccessToDelete()) {
94
            return $this->accessError();
95
        }
96
97
        return parent::actionDelete($id);
98
    }
99
100
    /**
101
     * Returns Product model name.
102
     *
103
     * @return string
104
     */
105
    protected function getModelName():string
106
    {
107
        return Product::class;
108
    }
109
110
    /**
111
     * Returns ProductSearch model name.
112
     *
113
     * @return string
114
     */
115
    protected function getSearchModelName():string
116
    {
117
        return ProductSearch::class;
118
    }
119
}
120