Code Duplication    Length = 31-31 lines in 2 locations

src/module/Appearance/Menu/Item/ItemDelController.php 1 location

@@ 9-39 (lines=31) @@
6
use Rudolf\Component\Alerts\AlertsCollection;
7
use Rudolf\Framework\Controller\AdminController;
8
9
class ItemDelController extends AdminController
10
{
11
    /**
12
     * @param $id
13
     *
14
     * @throws \Exception
15
     */
16
    public function del($id)
17
    {
18
        if (isset($_POST['delete'])) {
19
            $model = new ItemDelModel();
20
            if ($model->del($id)) {
21
                AlertsCollection::add(new Alert(
22
                    'success',
23
                    'Poprawnie usunięto!'
24
                ));
25
                $this->redirectTo(DIR.'/admin/appearance/menu');
26
                return;
27
            }
28
            AlertsCollection::add(new Alert(
29
                'error',
30
                'Coś się zepsuło!'
31
            ));
32
            $this->redirectTo(DIR.'/admin/appearance/menu/del/'.$id);
33
        }
34
35
        $view = new ItemDelView();
36
        $view->display((new ItemEditModel())->getInfo($id));
37
        $view->render();
38
    }
39
}
40

src/module/Appearance/Menu/Type/TypeDelController.php 1 location

@@ 9-39 (lines=31) @@
6
use Rudolf\Component\Alerts\AlertsCollection;
7
use Rudolf\Framework\Controller\AdminController;
8
9
class TypeDelController extends AdminController
10
{
11
    /**
12
     * @param $id
13
     *
14
     * @throws \Exception
15
     */
16
    public function del($id)
17
    {
18
        if (isset($_POST['delete'])) {
19
            $model = new TypeDelModel();
20
            if ($model->del($id)) {
21
                AlertsCollection::add(new Alert(
22
                    'success',
23
                    'Poprawnie usunięto!'
24
                ));
25
                $this->redirectTo(DIR.'/admin/appearance/menu');
26
                return;
27
            }
28
            AlertsCollection::add(new Alert(
29
                'error',
30
                'Coś się zepsuło!'
31
            ));
32
            $this->redirectTo(DIR.'/admin/appearance/menu/del-type/'.$id);
33
        }
34
35
        $view = new TypeDelView();
36
        $view->display((new TypeEditModel())->getMenuTypeById($id));
37
        $view->render();
38
    }
39
}
40