Code Duplication    Length = 18-19 lines in 2 locations

app/src/CommentDb/CommentController.php 1 location

@@ 190-207 (lines=18) @@
187
     *
188
     * @return void
189
     */
190
    public function editAction($id = null)
191
    {
192
        $this->di->session(); // Will load the session service which also starts the session
193
        $all = $this->comments->query()
194
            ->where("id = '$id'")
195
            ->execute();
196
        if (count($all)!=1) {
197
            die("Comment with id $id not found.");
198
        }
199
        $comment = $this->comments->find($id);
200
        $form = $this->createEditCommentForm($comment);
201
        $form->check([$this, 'callbackSuccess'], [$this, 'callbackFail']);
202
        $this->di->theme->setTitle("Edit comment");
203
        $this->di->views->add('default/page', [
204
            'title' => "Edit comment",
205
            'content' => $form->getHTML()
206
        ]);
207
    }
208
    private function createEditCommentForm($comment = null)
209
    {
210
        return $this->di->form->create([], [

app/src/Users/UsersController.php 1 location

@@ 228-246 (lines=19) @@
225
     *
226
     * @return void
227
     */
228
    public function updateAction($id = null)
229
    {
230
        $this->di->session(); // Will load the session service which also starts the session
231
        // Check if valid entry exists.
232
        $all = $this->users->query()
233
            ->where("id = '$id'")
234
            ->execute();
235
        if (count($all)!=1) {
236
            die("User with id $id not found.");
237
        }
238
        $user = $this->users->find($id);
239
        $form = $this->createUpdateUserForm($user);
240
        $form->check([$this, 'callbackSuccess'], [$this, 'callbackFail']);
241
        $this->di->theme->setTitle("Update user");
242
        $this->di->views->add('default/page', [
243
            'title' => "Update user",
244
            'content' => $form->getHTML()
245
        ]);
246
    }
247
    private function createUpdateUserForm($user = null)
248
    {
249
        return $this->di->form->create([], [