|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +/** |
| 8 | + * Module statuses manager |
| 9 | + */ |
7 | 10 | namespace Magento\Framework\Module;
|
8 | 11 |
|
9 | 12 | /**
|
|
17 | 20 | class Manager
|
18 | 21 | {
|
19 | 22 | /**
|
20 |
| - * The checker of output modules. |
21 |
| - * |
22 |
| - * @var Output\ConfigInterface the config checker of output modules. |
| 23 | + * @var Output\ConfigInterface |
23 | 24 | * @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version.
|
24 | 25 | * The property can be removed in a future major release
|
25 | 26 | */
|
26 |
| - private $outputConfig; |
| 27 | + private $_outputConfig; |
27 | 28 |
|
28 | 29 | /**
|
29 |
| - * The list of all modules. |
30 |
| - * |
31 |
| - * @var ModuleListInterface the list of all modules. |
| 30 | + * @var ModuleListInterface |
32 | 31 | */
|
33 |
| - private $moduleList; |
| 32 | + private $_moduleList; |
34 | 33 |
|
35 | 34 | /**
|
36 |
| - * The list of config paths to ignore. |
37 |
| - * |
38 |
| - * @var array the list of config paths to ignore. |
| 35 | + * @var array |
39 | 36 | * @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version.
|
40 | 37 | * The property can be removed in a future major release
|
41 | 38 | */
|
42 |
| - private $outputConfigPaths; |
| 39 | + private $_outputConfigPaths; |
43 | 40 |
|
44 | 41 | /**
|
45 |
| - * Constructor. |
46 |
| - * |
47 |
| - * @param Output\ConfigInterface $outputConfig the checker of output modules |
48 |
| - * @param ModuleListInterface $moduleList the list of all modules |
49 |
| - * @param array $outputConfigPaths the list of config paths to ignore |
| 42 | + * @param Output\ConfigInterface $outputConfig |
| 43 | + * @param ModuleListInterface $moduleList |
| 44 | + * @param array $outputConfigPaths |
50 | 45 | */
|
51 | 46 | public function __construct(
|
52 | 47 | Output\ConfigInterface $outputConfig,
|
53 | 48 | ModuleListInterface $moduleList,
|
54 | 49 | array $outputConfigPaths = []
|
55 | 50 | ) {
|
56 |
| - $this->outputConfig = $outputConfig; |
57 |
| - $this->moduleList = $moduleList; |
58 |
| - $this->outputConfigPaths = $outputConfigPaths; |
| 51 | + $this->_outputConfig = $outputConfig; |
| 52 | + $this->_moduleList = $moduleList; |
| 53 | + $this->_outputConfigPaths = $outputConfigPaths; |
59 | 54 | }
|
60 | 55 |
|
61 | 56 | /**
|
62 |
| - * Checks whether a module is enabled in the configuration or not. |
| 57 | + * Whether a module is enabled in the configuration or not |
63 | 58 | *
|
64 |
| - * @param string $moduleName the fully-qualified module name |
65 |
| - * |
66 |
| - * @return boolean true if module is enabled, false otherwise |
| 59 | + * @param string $moduleName Fully-qualified module name |
| 60 | + * @return boolean |
67 | 61 | */
|
68 | 62 | public function isEnabled($moduleName)
|
69 | 63 | {
|
70 |
| - return $this->moduleList->has($moduleName); |
| 64 | + return $this->_moduleList->has($moduleName); |
71 | 65 | }
|
72 | 66 |
|
73 | 67 | /**
|
74 |
| - * Checks whether a module output is permitted by the configuration or not. |
75 |
| - * |
76 |
| - * @param string $moduleName the fully-qualified module name. |
| 68 | + * Whether a module output is permitted by the configuration or not |
77 | 69 | *
|
| 70 | + * @param string $moduleName Fully-qualified module name |
78 | 71 | * @return boolean
|
79 | 72 | * @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
|
80 | 73 | */
|
81 | 74 | public function isOutputEnabled($moduleName)
|
82 | 75 | {
|
83 |
| - return $this->isEnabled($moduleName); |
| 76 | + if (!$this->isEnabled($moduleName)) { |
| 77 | + return false; |
| 78 | + } |
| 79 | + |
| 80 | + return true; |
84 | 81 | }
|
85 | 82 |
|
86 | 83 | /**
|
87 |
| - * Checks whether a configuration switch for a module output permits output. |
| 84 | + * Whether a configuration switch for a module output permits output or not |
88 | 85 | *
|
89 | 86 | * @param string $moduleName Fully-qualified module name
|
90 |
| - * |
91 | 87 | * @return boolean
|
92 |
| - * @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version. |
93 |
| - * The method can be removed in a future major release |
94 |
| - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 88 | + * @deprecated |
95 | 89 | */
|
96 | 90 | protected function _isCustomOutputConfigEnabled($moduleName)
|
97 | 91 | {
|
| 92 | + if (isset($this->_outputConfigPaths[$moduleName])) { |
| 93 | + $configPath = $this->_outputConfigPaths[$moduleName]; |
| 94 | + if (defined($configPath)) { |
| 95 | + $configPath = constant($configPath); |
| 96 | + } |
| 97 | + return $this->_outputConfig->isSetFlag($configPath); |
| 98 | + } |
98 | 99 | return true;
|
99 | 100 | }
|
100 | 101 | }
|
0 commit comments