Passed
Push — master ( 08f33a...dc0f7f )
by Romain
06:16 queued 03:01
created

ModuleHandler::forModule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
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
     * @PHP7 rename method to `for`
49
     *
50
     * @param string $module
51
     * @return ModuleHandler
52
     */
53
    public static function forModule($module)
54
    {
55
        /** @var ModuleHandler $moduleHandler */
56
        $moduleHandler = Container::get(__NAMESPACE__ . '\\' . $module . 'ModuleHandler');
57
58
        return $moduleHandler;
59
    }
60
61
    /**
62
     * @return UriBuilder
63
     */
64
    public function getUriBuilder()
65
    {
66
        return $this->uriBuilder;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    abstract public function getDefaultControllerName();
73
74
    /**
75
     * @return string
76
     */
77
    abstract public function getModuleName();
78
}
79