Code Duplication    Length = 12-13 lines in 4 locations

base/ItemController.php 2 locations

@@ 104-116 (lines=13) @@
101
     *
102
     * @return mixed
103
     */
104
    public function actionCreate()
105
    {
106
        $model = new AuthItemModel();
107
        $model->type = $this->type;
108
109
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
110
            Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Item has been saved.'));
111
112
            return $this->redirect(['view', 'id' => $model->name]);
113
        }
114
115
        return $this->render('create', ['model' => $model]);
116
    }
117
118
    /**
119
     * Updates an existing AuthItem model.
@@ 127-138 (lines=12) @@
124
     *
125
     * @return mixed
126
     */
127
    public function actionUpdate(string $id)
128
    {
129
        $model = $this->findModel($id);
130
131
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
132
            Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Item has been saved.'));
133
134
            return $this->redirect(['view', 'id' => $model->name]);
135
        }
136
137
        return $this->render('update', ['model' => $model]);
138
    }
139
140
    /**
141
     * Deletes an existing AuthItem model.

controllers/RuleController.php 2 locations

@@ 84-95 (lines=12) @@
81
     *
82
     * @return mixed
83
     */
84
    public function actionCreate()
85
    {
86
        $model = new BizRuleModel();
87
88
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
89
            Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Rule has been saved.'));
90
91
            return $this->redirect(['view', 'id' => $model->name]);
92
        }
93
94
        return $this->render('create', ['model' => $model]);
95
    }
96
97
    /**
98
     * Updates an existing Rule item.
@@ 106-117 (lines=12) @@
103
     *
104
     * @return mixed
105
     */
106
    public function actionUpdate(string $id)
107
    {
108
        $model = $this->findModel($id);
109
110
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
111
            Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Rule has been saved.'));
112
113
            return $this->redirect(['view', 'id' => $model->name]);
114
        }
115
116
        return $this->render('update', ['model' => $model]);
117
    }
118
119
    /**
120
     * Deletes an existing Rule item.