1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Admin\Main; |
||
4 | |||
5 | |||
6 | use Apps\Model\Admin\Main\FormYandexToken; |
||
7 | use Ffcms\Core\App; |
||
8 | use Ffcms\Core\Arch\View; |
||
9 | use Ffcms\Core\Helper\Date; |
||
10 | use Ffcms\Core\Network\Request; |
||
11 | use Ffcms\Core\Network\Response; |
||
12 | |||
13 | /** |
||
14 | * Trait ActionYandexToken |
||
15 | * @package Apps\Controller\Admin\Main |
||
16 | * @property Request $request |
||
17 | * @property Response $response |
||
18 | * @property View $view |
||
19 | */ |
||
20 | trait ActionYandexToken |
||
21 | { |
||
22 | /** |
||
23 | * @return string|null |
||
24 | * @throws \Ffcms\Core\Exception\SyntaxException |
||
25 | */ |
||
26 | public function yandexToken(): ?string |
||
27 | { |
||
28 | $cfg = App::$Properties->getAll('Yandex'); |
||
29 | |||
30 | $model = new FormYandexToken($cfg); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
31 | if ($model->send() && $model->validate()) { |
||
32 | $model->make(); |
||
33 | App::$Session->getFlashBag()->add('success', __('Token saved successful. Valid until: %date%', [ |
||
34 | 'date' => Date::convertToDatetime(time() + $model->expires, Date::FORMAT_TO_DAY) |
||
35 | ])); |
||
36 | $this->response->redirect('main/yandexcounter'); |
||
37 | } |
||
38 | |||
39 | return $this->view->render('main/yandex_token', [ |
||
40 | 'model' => $model |
||
41 | ]); |
||
42 | } |
||
43 | } |