Code Duplication    Length = 11-11 lines in 3 locations

src/Controller/Admin/AttachmentsController.php 2 locations

@@ 68-78 (lines=11) @@
65
                ->first();
66
67
            //Check if the article has already an attachment
68
            if (!is_null($article->blog_attachment)) {
69
                $this->Flash->error(
70
                    __d(
71
                        'admin',
72
                        'This article has already an attachment, you can edit it <a href="{0}" class="btn btn-sm btn-danger">here</a>.',
73
                        Router::url(['_name' => 'attachments-edit', 'id' => $article->blog_attachment->id])
74
                    )
75
                );
76
77
                return $this->redirect(['action' => 'index']);
78
            }
79
80
            $attachment->user_id = $this->Auth->user('id');
81
            $attachment->accessible('url_file', true);
@@ 140-150 (lines=11) @@
137
                ])
138
                ->first();
139
140
            if (!is_null($article->blog_attachment) && $article->blog_attachment->id != $this->request->id) {
141
                $this->Flash->error(
142
                    __d(
143
                        'admin',
144
                        'This article has already an attachment, you can edit it <a href="{0}" class="btn btn-sm btn-danger">here</a>.',
145
                        Router::url(['_name' => 'attachments-edit', 'id' => $article->blog_attachment->id])
146
                    )
147
                );
148
149
                return $this->redirect(['action' => 'index']);
150
            }
151
152
            $attachment->user_id = $this->Auth->user('id');
153
            $attachment->accessible('url_file', true);

src/Controller/Admin/PollsController.php 1 location

@@ 64-74 (lines=11) @@
61
                ->first();
62
63
            //Check if the article has already a poll
64
            if (!is_null($article->poll)) {
65
                $this->Flash->error(
66
                    __d(
67
                        'admin',
68
                        'This article has already a poll, you can edit it <a href="{0}" class="btn btn-sm btn-danger-outline">here</a>.',
69
                        Router::url(['_name' => 'polls-edit', 'id' => $article->poll->id, 'slug' => $article->poll->name])
70
                    )
71
                );
72
73
                return $this->redirect(['action' => 'index']);
74
            }
75
76
            $pollAnswers = [];
77