Code Duplication    Length = 21-21 lines in 2 locations

controllers/DeviceController.php 1 location

@@ 122-142 (lines=21) @@
119
     *
120
     * @return \yii\web\Response|string redirec or render
121
     */
122
    public function actionLink($id, $screenId = null)
123
    {
124
        $model = $this->findModel($id);
125
126
        if ($screenId === null) {
127
            $dataProvider = new ActiveDataProvider([
128
                'query' => Screen::find()->where(['not', ['id' => ArrayHelper::getColumn($model->screens, 'id')]]),
129
            ]);
130
131
            return $this->render('link', [
132
                'model' => $model,
133
                'dataProvider' => $dataProvider,
134
            ]);
135
        } else {
136
            if (!$model->getScreens()->where(['id' => $screenId])->exists() && ($screen = Screen::findOne($screenId)) !== null) {
137
                $model->link('screens', $screen);
138
            }
139
140
            return $this->redirect(['view', 'id' => $id]);
141
        }
142
    }
143
144
    /**
145
     * Remove a Screen from a Device.

controllers/ScreenController.php 1 location

@@ 171-191 (lines=21) @@
168
     *
169
     * @return \yii\web\Response|string redirect or render
170
     */
171
    public function actionLink($id, $flowId = null)
172
    {
173
        $model = $this->findModel($id);
174
175
        if ($flowId === null) {
176
            $dataProvider = new ActiveDataProvider([
177
                'query' => Flow::find()->where(['not', ['id' => ArrayHelper::getColumn($model->flows, 'id')]]),
178
            ]);
179
180
            return $this->render('link', [
181
                'model' => $model,
182
                'dataProvider' => $dataProvider,
183
            ]);
184
        } else {
185
            if (!$model->getFlows()->where(['id' => $flowId])->exists() && ($flow = Flow::findOne($flowId)) !== null) {
186
                $model->link('flows', $flow);
187
            }
188
189
            return $this->redirect(['view', 'id' => $id]);
190
        }
191
    }
192
193
    /**
194
     * Remove a flow from a screen.