Passed
Push — master ( e28a27...ade361 )
by Gabor
22:04 queued 18:53
created

ViewAction::getUserGroupDetails()   B

Complexity

Conditions 6
Paths 9

Size

Total Lines 37
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 23
nc 9
nop 1
dl 0
loc 37
rs 8.9297
c 0
b 0
f 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Middleware\Action\Admin\ControlPanel\Groups;
15
16
use RuntimeException;
17
use WebHemi\Configuration\ServiceInterface as ConfigurationInterface;
18
use WebHemi\Data\Entity\UserGroupEntity;
19
use WebHemi\Data\Storage\UserStorage;
20
use WebHemi\DateTime;
21
use WebHemi\Environment\ServiceInterface as EnvironmentInterface;
22
use WebHemi\Middleware\Action\AbstractMiddlewareAction;
23
24
/**
25
 * Class ViewAction
26
 */
27
class ViewAction extends AbstractMiddlewareAction
28
{
29
    /**
30
     * @var ConfigurationInterface
31
     */
32
    protected $configuration;
33
    /**
34
     * @var EnvironmentInterface
35
     */
36
    protected $environmentManager;
37
    /**
38
     * @var UserStorage
39
     */
40
    protected $userStorage;
41
42
    /**
43
     * GroupManagementAction constructor.
44
     *
45
     * @param ConfigurationInterface $configuration
46
     * @param EnvironmentInterface   $environmentManager
47
     * @param UserStorage            $userStorage
48
     */
49
    public function __construct(
50
        ConfigurationInterface $configuration,
51
        EnvironmentInterface $environmentManager,
52
        UserStorage $userStorage
53
    ) {
54
        $this->configuration = $configuration;
55
        $this->environmentManager = $environmentManager;
56
        $this->userStorage = $userStorage;
57
    }
58
59
    /**
60
     * Gets template map name or template file path.
61
     *
62
     * @return string
63
     */
64
    public function getTemplateName() : string
65
    {
66
        return 'admin-control-panel-groups-view';
67
    }
68
69
    /**
70
     * Gets template data.
71
     *
72
     * @return array
73
     */
74
    public function getTemplateData() : array
75
    {
76
        $data = null;
77
78
        $params = $this->getRoutingParameters();
79
80
        if (isset($params['name'])) {
81
            $data = $this->userStorage->getUserGroupByName($params['name']);
82
        }
83
84
        return [
85
            'data' => $data,
86
        ];
87
    }
88
}
89