1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Admin\Content; |
||
4 | |||
5 | use Apps\ActiveRecord\Content as ContentEntity; |
||
6 | use Apps\Model\Admin\Content\FormContentClear; |
||
7 | use Ffcms\Core\App; |
||
8 | use Ffcms\Core\Arch\View; |
||
9 | use Ffcms\Core\Network\Request; |
||
10 | use Ffcms\Core\Network\Response; |
||
11 | |||
12 | /** |
||
13 | * Trait ActionClear |
||
14 | * @package Apps\Controller\Admin\Content |
||
15 | * @property Request $request |
||
16 | * @property Response $response |
||
17 | * @property View $view |
||
18 | */ |
||
19 | trait ActionClear |
||
20 | { |
||
21 | /** |
||
22 | * Clear all trashed items |
||
23 | * @return string |
||
24 | * @throws \Ffcms\Core\Exception\SyntaxException |
||
25 | */ |
||
26 | public function clear(): ?string |
||
27 | { |
||
28 | // find trashed rows |
||
29 | $records = ContentEntity::onlyTrashed(); |
||
30 | |||
31 | // init model |
||
32 | $model = new FormContentClear($records); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
33 | if ($model->send() && $model->validate()) { |
||
34 | $model->make(); |
||
35 | App::$Session->getFlashBag()->add('success', __('Trash content is cleaned')); |
||
36 | $this->response->redirect('content/index'); |
||
37 | } |
||
38 | |||
39 | // draw response |
||
40 | return $this->view->render('content/content_clear', [ |
||
41 | 'model' => $model |
||
42 | ]); |
||
43 | } |
||
44 | } |
||
45 |