Passed
Push — master ( 313c53...eadb07 )
by Mihail
04:44
created

ActionInviteSend   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A inviteSend() 0 20 4
1
<?php
2
3
namespace Apps\Controller\Admin\User;
4
5
use Apps\Model\Admin\User\FormInviteSend;
6
use Ffcms\Core\App;
7
use Ffcms\Core\Arch\View;
8
use Ffcms\Core\Network\Request;
9
use Ffcms\Core\Network\Response;
10
11
/**
12
 * Trait ActionInvite
13
 * @package Apps\Controller\Admin\User
14
 * @property Request $request
15
 * @property Response $response
16
 * @property View $view
17
 */
18
trait ActionInviteSend
19
{
20
    /**
21
     * Send invite to user by email
22
     * @return string|null
23
     * @throws \Ffcms\Core\Exception\SyntaxException
24
     */
25
    public function inviteSend(): ?string
26
    {
27
        // init model
28
        $model = new FormInviteSend();
29
30
        if ($model->send()) {
31
            if ($model->validate()) {
32
                if ($model->make()) {
33
                    App::$Session->getFlashBag()->add('success', __('Invite was successful send!'));
34
                } else {
35
                    App::$Session->getFlashBag()->add('error', __('Mail server connection is failed!'));
36
                }
37
            } else {
38
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
39
            }
40
        }
41
42
        // render view
43
        return $this->view->render('user/invite', [
44
            'model' => $model
45
        ]);
46
    }
47
}
48