Code Duplication    Length = 32-33 lines in 2 locations

app/modules/Page/Controller/AdminController.php 1 location

@@ 32-63 (lines=32) @@
29
        $this->helper->title($this->helper->at('Manage Pages'), true);
30
    }
31
32
    public function addAction()
33
    {
34
        $this->view->pick(['admin/edit']);
35
        $form = new PageForm();
36
        $model = new Page();
37
38
        if ($this->request->isPost()) {
39
            $post = $this->request->getPost();
40
            $form->bind($post, $model);
41
            if ($form->isValid()) {
42
                if ($model->create()) {
43
                    $form->bind($post, $model);
44
                    $model->updateFields($post);
45
                    if ($model->update()) {
46
                        $this->flash->success($this->helper->at('Page created'));
47
                        return $this->redirect($this->url->get() . 'page/admin/edit/' . $model->getId() . '?lang=' . LANG);
48
                    } else {
49
                        $this->flashErrors($model);
50
                    }
51
                } else {
52
                    $this->flashErrors($model);
53
                }
54
            } else {
55
                $this->flashErrors($form);
56
            }
57
        }
58
59
        $this->helper->title($this->helper->at('Manage Pages'), true);
60
61
        $this->view->model = $model;
62
        $this->view->form = $form;
63
    }
64
65
    public function editAction($id)
66
    {

app/modules/Publication/Controller/TypeController.php 1 location

@@ 28-60 (lines=33) @@
25
        $this->helper->title('Manage Types of Publication', true);
26
    }
27
28
    public function addAction()
29
    {
30
        $this->view->pick(array('type/edit'));
31
32
        $form = new TypeForm();
33
        $model = new Type();
34
35
        if ($this->request->isPost()) {
36
            $post = $this->request->getPost();
37
            $form->bind($post, $model);
38
39
            if ($form->isValid()) {
40
                if ($model->create()) {
41
                    $form->bind($post, $model);
42
                    $model->updateFields($post);
43
                    if ($model->update()) {
44
                        $this->flash->success('Type created');
45
                        return $this->redirect($this->url->get() . 'publication/type/edit/' . $model->getId() . '?lang=' . LANG);
46
                    } else {
47
                        $this->flashErrors($model);
48
                    }
49
                } else {
50
                    $this->flashErrors($model);
51
                }
52
            } else {
53
                $this->flashErrors($form);
54
            }
55
        }
56
57
        $this->view->model = $model;
58
        $this->view->form = $form;
59
        $this->helper->title($this->helper->at('Adding Type of Publication'));
60
    }
61
62
    public function editAction($id)
63
    {