Code Duplication    Length = 24-28 lines in 3 locations

Apps/Controller/Admin/Content.php 3 locations

@@ 118-141 (lines=24) @@
115
     * @throws \Ffcms\Core\Exception\SyntaxException
116
     * @throws \Ffcms\Core\Exception\NativeException
117
     */
118
    public function actionDelete($id)
119
    {
120
        if (!Obj::isLikeInt($id) || $id < 1) {
121
            throw new NotFoundException();
122
        }
123
124
        // get content record and check availability
125
        $record = ContentEntity::find($id);
126
        if ($record === null || $record === false) {
127
            throw new NotFoundException();
128
        }
129
130
        // init delete model
131
        $model = new FormContentDelete($record);
132
        if ($model->send() && $model->validate()) {
133
            $model->make();
134
            App::$Session->getFlashBag()->add('success', __('Content is successful moved to trash'));
135
            App::$Response->redirect('content/index');
136
        }
137
138
        return App::$View->render('content_delete', [
139
            'model' => $model->export()
140
        ]);
141
    }
142
143
    /**
144
     * Restore deleted content
@@ 151-176 (lines=26) @@
148
     * @throws SyntaxException
149
     * @throws \Ffcms\Core\Exception\NativeException
150
     */
151
    public function actionRestore($id)
152
    {
153
        if (!Obj::isLikeInt($id) || $id < 1) {
154
            throw new NotFoundException();
155
        }
156
157
        // get removed object
158
        $record = ContentEntity::onlyTrashed()->find($id);
159
        if ($record === null || $record === false) {
160
            throw new NotFoundException();
161
        }
162
163
        // init model
164
        $model = new FormContentRestore($record);
165
        // check if action is send
166
        if ($model->send() && $model->validate()) {
167
            $model->make();
168
            App::$Session->getFlashBag()->add('success', __('Content are successful recovered'));
169
            App::$Response->redirect('content/index');
170
        }
171
172
        // draw response
173
        return App::$View->render('content_restore', [
174
            'model' => $model->export()
175
        ]);
176
    }
177
178
    /**
179
     * Clear the trashed items
@@ 228-255 (lines=28) @@
225
     * @throws \Ffcms\Core\Exception\SyntaxException
226
     * @throws \Ffcms\Core\Exception\NativeException
227
     */
228
    public function actionCategorydelete($id)
229
    {
230
        // check id
231
        if (!Obj::isLikeInt($id) || $id < 2) {
232
            throw new ForbiddenException();
233
        }
234
235
        // get object relation
236
        $record = ContentCategory::find($id);
237
        if ($record === null || $record === false) {
238
            throw new ForbiddenException();
239
        }
240
241
        // init model with object relation
242
        $model = new FormCategoryDelete($record);
243
244
        // check if delete is submited
245
        if ($model->send() && $model->validate()) {
246
            $model->make();
247
            App::$Session->getFlashBag()->add('success', __('Category is successful removed'));
248
            App::$Response->redirect('content/categories');
249
        }
250
251
        // draw view
252
        return App::$View->render('category_delete', [
253
            'model' => $model->export()
254
        ]);
255
    }
256
257
    /**
258
     * Show category edit and create