Passed
Push — master ( 1afd07...b44614 )
by Romain
03:20
created

ModuleHandler::for()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright (C) 2018
5
 * Nathan Boiron <[email protected]>
6
 * Romain Canon <[email protected]>
7
 *
8
 * This file is part of the TYPO3 NotiZ project.
9
 * It is free software; you can redistribute it and/or modify it
10
 * under the terms of the GNU General Public License, either
11
 * version 3 of the License, or any later version.
12
 *
13
 * For the full copyright and license information, see:
14
 * http://www.gnu.org/licenses/gpl-3.0.html
15
 */
16
17
namespace CuyZ\Notiz\Backend\Module;
18
19
use CuyZ\Notiz\Backend\Module\Uri\UriBuilder;
20
use CuyZ\Notiz\Core\Definition\DefinitionService;
21
use CuyZ\Notiz\Service\Container;
22
use TYPO3\CMS\Core\SingletonInterface;
23
24
abstract class ModuleHandler implements SingletonInterface
25
{
26
    /**
27
     * @var DefinitionService
28
     */
29
    protected $definitionService;
30
31
    /**
32
     * @var UriBuilder
33
     */
34
    protected $uriBuilder;
35
36
    /**
37
     * @param DefinitionService $definitionService
38
     */
39
    public function __construct(DefinitionService $definitionService)
40
    {
41
        $this->definitionService = $definitionService;
42
        $this->uriBuilder = Container::get(UriBuilder::class, $this);
43
    }
44
45
    /**
46
     * Returns the manager instance for the given module.
47
     *
48
     * @param string $module
49
     * @return ModuleHandler
50
     */
51
    public static function for($module)
52
    {
53
        /** @var ModuleHandler $moduleHandler */
54
        $moduleHandler = Container::get(__NAMESPACE__ . '\\' . $module . 'ModuleHandler');
55
56
        return $moduleHandler;
57
    }
58
59
    /**
60
     * @return UriBuilder
61
     */
62
    public function getUriBuilder()
63
    {
64
        return $this->uriBuilder;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    abstract public function getDefaultControllerName();
71
72
    /**
73
     * @return string
74
     */
75
    abstract public function getModuleName();
76
}
77