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