Completed
Push — master ( 874c42...3f0650 )
by Ryan
02:09
created

UsersModulePlugin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 10

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 1
c 5
b 0
f 0
lcom 0
cbo 10
dl 0
loc 78
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 69 1
1
<?php namespace Anomaly\UsersModule;
2
3
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
4
use Anomaly\UsersModule\User\Command\BuildCompleteResetForm;
5
use Anomaly\UsersModule\User\Command\BuildLoginForm;
6
use Anomaly\UsersModule\User\Command\BuildRegisterForm;
7
use Anomaly\UsersModule\User\Command\BuildResetForm;
8
use Anomaly\UsersModule\User\Command\CheckUserPermission;
9
use Anomaly\UsersModule\User\Command\CheckUserRole;
10
use Anomaly\UsersModule\User\Command\GetActivatePath;
11
use Anomaly\UsersModule\User\Command\GetCompleteResetPath;
12
use Anomaly\UsersModule\User\Command\GetLoginPath;
13
use Anomaly\UsersModule\User\Command\GetLogoutPath;
14
15
/**
16
 * Class UsersModulePlugin
17
 *
18
 * @link          http://anomaly.is/streams-platform
19
 * @author        AnomalyLabs, Inc. <[email protected]>
20
 * @author        Ryan Thompson <[email protected]>
21
 * @package       Anomaly\UsersModule
22
 */
23
class UsersModulePlugin extends Plugin
24
{
25
26
    /**
27
     * Get the functions.
28
     *
29
     * @return array
30
     */
31
    public function getFunctions()
32
    {
33
        return [
34
            new \Twig_SimpleFunction(
35
                'user_has_role',
36
                function ($identifier) {
37
                    return $this->dispatch(new CheckUserRole($identifier));
38
                }
39
            ),
40
            new \Twig_SimpleFunction(
41
                'user_has_permission',
42
                function ($permission) {
43
                    return $this->dispatch(new CheckUserPermission($permission));
44
                }
45
            ),
46
            new \Twig_SimpleFunction(
47
                'login_form',
48
                function (array $parameters = []) {
49
                    return $this->dispatch(new BuildLoginForm($parameters));
50
                },
51
                ['is_safe' => ['html']]
52
            ),
53
            new \Twig_SimpleFunction(
54
                'register_form',
55
                function (array $parameters = []) {
56
                    return $this->dispatch(new BuildRegisterForm($parameters));
57
                },
58
                ['is_safe' => ['html']]
59
            ),
60
            new \Twig_SimpleFunction(
61
                'reset_form',
62
                function (array $parameters = []) {
63
                    return $this->dispatch(new BuildResetForm($parameters));
64
                },
65
                ['is_safe' => ['html']]
66
            ),
67
            new \Twig_SimpleFunction(
68
                'complete_reset_form',
69
                function (array $parameters = []) {
70
                    return $this->dispatch(new BuildCompleteResetForm($parameters));
71
                },
72
                ['is_safe' => ['html']]
73
            ),
74
            new \Twig_SimpleFunction(
75
                'login_path',
76
                function () {
77
                    return $this->dispatch(new GetLoginPath());
78
                }
79
            ),
80
            new \Twig_SimpleFunction(
81
                'logout_path',
82
                function ($redirect = null) {
83
                    return $this->dispatch(new GetLogoutPath($redirect));
84
                }
85
            ),
86
            new \Twig_SimpleFunction(
87
                'activate_path',
88
                function (UserInterface $user) {
89
                    return $this->dispatch(new GetActivatePath($user));
90
                }
91
            ),
92
            new \Twig_SimpleFunction(
93
                'complete_reset_path',
94
                function (UserInterface $user) {
95
                    return $this->dispatch(new GetCompleteResetPath($user));
96
                }
97
            )
98
        ];
99
    }
100
}
101