Code Duplication    Length = 10-10 lines in 3 locations

src/Controller/Admin/ArticlesController.php 2 locations

@@ 63-72 (lines=10) @@
60
        $this->BlogArticles->locale(I18n::defaultLocale());
61
        $article = $this->BlogArticles->newEntity($this->request->data);
62
63
        if ($this->request->is('post')) {
64
            $article->user_id = $this->Auth->user('id');
65
            $article->setTranslations($this->request->data);
66
67
            if ($this->BlogArticles->save($article)) {
68
                $this->Flash->success(__d('admin', 'Your article has been created successfully !'));
69
70
                return $this->redirect(['action' => 'index']);
71
            }
72
        }
73
74
        $categories = $this->BlogArticles->BlogCategories->find('list');
75
@@ 110-119 (lines=10) @@
107
            return $this->redirect(['action' => 'index']);
108
        }
109
110
        if ($this->request->is('put')) {
111
            $this->BlogArticles->patchEntity($article, $this->request->data());
112
            $article->setTranslations($this->request->data);
113
114
            if ($this->BlogArticles->save($article)) {
115
                $this->Flash->success(__d('admin', 'This article has been updated successfully !'));
116
117
                return $this->redirect(['action' => 'index']);
118
            }
119
        }
120
121
        $categories = $this->BlogArticles->BlogCategories->find('list');
122
        $this->set(compact('article', 'categories'));

src/Controller/Admin/CategoriesController.php 1 location

@@ 82-91 (lines=10) @@
79
            return $this->redirect(['action' => 'index']);
80
        }
81
82
        if ($this->request->is('put')) {
83
            $this->BlogCategories->patchEntity($category, $this->request->data());
84
            $category->setTranslations($this->request->data);
85
86
            if ($this->BlogCategories->save($category)) {
87
                $this->Flash->success(__d('admin', 'This category has been updated successfully !'));
88
89
                return $this->redirect(['action' => 'index']);
90
            }
91
        }
92
93
        $this->set(compact('category'));
94
    }