Completed
Push — master ( 85c302...eb8262 )
by Ryan
01:49
created

UsersModulePlugin::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
c 9
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php namespace Anomaly\UsersModule;
2
3
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
4
use Anomaly\Streams\Platform\Support\Decorator;
5
use Anomaly\UsersModule\Role\Command\GetRole;
6
use Anomaly\UsersModule\User\Command\GetUser;
7
8
/**
9
 * Class UsersModulePlugin
10
 *
11
 * @link          http://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 * @package       Anomaly\UsersModule
15
 */
16
class UsersModulePlugin extends Plugin
17
{
18
19
    /**
20
     * Get the functions.
21
     *
22
     * @return array
23
     */
24
    public function getFunctions()
25
    {
26
        return [
27
            new \Twig_SimpleFunction(
28
                'user',
29
                function ($identifier = null) {
30
                    return (new Decorator())->decorate($this->dispatch(new GetUser($identifier)));
31
                }
32
            ),
33
            new \Twig_SimpleFunction(
34
                'role',
35
                function ($identifier) {
36
                    return (new Decorator())->decorate($this->dispatch(new GetRole($identifier)));
37
                }
38
            )
39
        ];
40
    }
41
}
42