Code Duplication    Length = 18-23 lines in 5 locations

Apps/Controller/Admin/Content.php 1 location

@@ 336-356 (lines=21) @@
333
     * @return string
334
     * @throws SyntaxException
335
     */
336
    public function actionSettings()
337
    {
338
        // init model with config array data
339
        $model = new FormSettings($this->getConfigs());
340
341
        // check if form is send
342
        if ($model->send()) {
343
            if ($model->validate()) {
344
                $this->setConfigs($model->getAllProperties());
345
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
346
                App::$Response->redirect('content/index');
347
            } else {
348
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
349
            }
350
        }
351
352
        // draw response
353
        return App::$View->render('settings', [
354
            'model' => $model->export()
355
        ]);
356
    }
357
}

Apps/Controller/Admin/Profile.php 1 location

@@ 183-200 (lines=18) @@
180
     * @return string
181
     * @throws \Ffcms\Core\Exception\SyntaxException
182
     */
183
    public function actionSettings()
184
    {
185
        $model = new FormSettings($this->getConfigs());
186
187
        if ($model->send()) {
188
            if ($model->validate()) {
189
                $this->setConfigs($model->getAllProperties());
190
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
191
                App::$Response->redirect('profile/index');
192
            } else {
193
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
194
            }
195
        }
196
197
        return App::$View->render('settings', [
198
            'model' => $model
199
        ]);
200
    }
201
202
203
}

Apps/Controller/Admin/User.php 1 location

@@ 162-181 (lines=20) @@
159
     * User identity settings
160
     * @return string
161
     */
162
    public function actionSettings()
163
    {
164
        // load model and pass property's as argument
165
        $model = new FormUserSettings($this->getConfigs());
166
167
        if ($model->send()) {
168
            if ($model->validate()) {
169
                $this->setConfigs($model->getAllProperties());
170
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
171
                App::$Response->redirect('user/index');
172
            } else {
173
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
174
            }
175
        }
176
177
        // render view
178
        return App::$View->render('settings', [
179
            'model' => $model->export()
180
        ]);
181
    }
182
183
    /**
184
     * Send invite to user by email

Apps/Controller/Admin/Feedback.php 1 location

@@ 233-255 (lines=23) @@
230
     * @return string
231
     * @throws \Ffcms\Core\Exception\SyntaxException
232
     */
233
    public function actionSettings()
234
    {
235
        // initialize model and pass configs
236
        $model = new FormSettings($this->getConfigs());
237
238
        // check if form is submited to save data
239
        if ($model->send()) {
240
            // is validation passed?
241
            if ($model->validate()) {
242
                // save properties
243
                $this->setConfigs($model->getAllProperties());
244
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
245
                App::$Response->redirect('feedback/index');
246
            } else {
247
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
248
            }
249
        }
250
251
        // render view
252
        return App::$View->render('settings', [
253
            'model' => $model
254
        ]);
255
    }
256
257
}

Apps/Controller/Admin/Comments.php 1 location

@@ 268-288 (lines=21) @@
265
     * @return string
266
     * @throws \Ffcms\Core\Exception\SyntaxException
267
     */
268
    public function actionSettings()
269
    {
270
        // initialize settings model
271
        $model = new FormSettings($this->getConfigs());
272
273
        // check if form is send
274
        if ($model->send()) {
275
            if ($model->validate()) {
276
                $this->setConfigs($model->getAllProperties());
277
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
278
                App::$Response->redirect('comments/index');
279
            } else {
280
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
281
            }
282
        }
283
284
        // render view
285
        return App::$View->render('settings', [
286
            'model' => $model
287
        ]);
288
    }
289
290
291