Code Duplication    Length = 18-23 lines in 6 locations

Apps/Controller/Admin/Feedback.php 1 location

@@ 246-268 (lines=23) @@
243
     * @throws \Ffcms\Core\Exception\NativeException
244
     * @throws \Ffcms\Core\Exception\SyntaxException
245
     */
246
    public function actionSettings()
247
    {
248
        // initialize model and pass configs
249
        $model = new FormSettings($this->getConfigs());
250
251
        // check if form is submited to save data
252
        if ($model->send()) {
253
            // is validation passed?
254
            if ($model->validate()) {
255
                // save properties
256
                $this->setConfigs($model->getAllProperties());
257
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
258
                $this->response->redirect('feedback/index');
259
            } else {
260
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
261
            }
262
        }
263
264
        // render view
265
        return $this->view->render('settings', [
266
            'model' => $model->filter()
267
        ]);
268
    }
269
270
}

Apps/Controller/Admin/Comments.php 1 location

@@ 279-299 (lines=21) @@
276
     * @throws \Ffcms\Core\Exception\NativeException
277
     * @throws \Ffcms\Core\Exception\SyntaxException
278
     */
279
    public function actionSettings()
280
    {
281
        // initialize settings model
282
        $model = new FormSettings($this->getConfigs());
283
284
        // check if form is send
285
        if ($model->send()) {
286
            if ($model->validate()) {
287
                $this->setConfigs($model->getAllProperties());
288
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
289
                $this->response->redirect('comments/index');
290
            } else {
291
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
292
            }
293
        }
294
295
        // render view
296
        return $this->view->render('settings', [
297
            'model' => $model
298
        ]);
299
    }
300
301
302

Apps/Controller/Admin/Content.php 1 location

@@ 377-397 (lines=21) @@
374
     * @throws SyntaxException
375
     * @throws NativeException
376
     */
377
    public function actionSettings()
378
    {
379
        // init model with config array data
380
        $model = new FormSettings($this->getConfigs());
381
382
        // check if form is send
383
        if ($model->send()) {
384
            if ($model->validate()) {
385
                $this->setConfigs($model->getAllProperties());
386
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
387
                $this->response->redirect('content/index');
388
            } else {
389
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
390
            }
391
        }
392
393
        // draw response
394
        return $this->view->render('settings', [
395
            'model' => $model
396
        ]);
397
    }
398
}

Apps/Controller/Admin/Profile.php 1 location

@@ 196-213 (lines=18) @@
193
     * @throws \Ffcms\Core\Exception\NativeException
194
     * @throws \Ffcms\Core\Exception\SyntaxException
195
     */
196
    public function actionSettings()
197
    {
198
        $model = new FormSettings($this->getConfigs());
199
200
        if ($model->send()) {
201
            if ($model->validate()) {
202
                $this->setConfigs($model->getAllProperties());
203
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
204
                $this->response->redirect('profile/index');
205
            } else {
206
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
207
            }
208
        }
209
210
        return $this->view->render('settings', [
211
            'model' => $model
212
        ]);
213
    }
214
215
216
}

Apps/Controller/Admin/Search.php 1 location

@@ 26-47 (lines=22) @@
23
     * @throws \Ffcms\Core\Exception\SyntaxException
24
     * @throws \Ffcms\Core\Exception\NativeException
25
     */
26
    public function actionIndex()
27
    {
28
        // initialize model and pass configs inside
29
        $model = new FormSettings($this->getConfigs());
30
31
        // check if submit request is sended
32
        if ($model->send()) {
33
            if ($model->validate()) {
34
                // save configurations
35
                $this->setConfigs($model->getAllProperties());
36
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
37
                $this->response->redirect('search/index');
38
            } else {
39
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
40
            }
41
        }
42
43
        // render output view
44
        return $this->view->render('settings', [
45
            'model' => $model
46
        ]);
47
    }
48
49
}

Apps/Controller/Admin/User.php 1 location

@@ 186-205 (lines=20) @@
183
     * @throws \Ffcms\Core\Exception\SyntaxException
184
     * @throws \Ffcms\Core\Exception\NativeException
185
     */
186
    public function actionSettings()
187
    {
188
        // load model and pass property's as argument
189
        $model = new FormUserSettings($this->getConfigs());
190
191
        if ($model->send()) {
192
            if ($model->validate()) {
193
                $this->setConfigs($model->getAllProperties());
194
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
195
                $this->response->redirect('user/index');
196
            } else {
197
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
198
            }
199
        }
200
201
        // render view
202
        return $this->view->render('settings', [
203
            'model' => $model
204
        ]);
205
    }
206
207
    /**
208
     * Send invite to user by email