Skip to content

Commit a761cc7

Browse files
author
Dale Sikkema
committed
MAGETWO-38031: [GITHUB] Allow modules to live outside of app/code directory #1206
- more description in docblocks
1 parent df9bd34 commit a761cc7

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

lib/internal/Magento/Framework/Module/Dir.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515

1616
class Dir
1717
{
18+
/**#@+
19+
* Directories within modules
20+
*/
21+
const MODULE_ETC_DIR = 'etc';
22+
const MODULE_I18N_DIR = 'i18n';
23+
const MODULE_VIEW_DIR = 'view';
24+
const MODULE_CONTROLLER_DIR = 'Controller';
25+
/**#@-*/
26+
1827
/**
1928
* Modules root directory
2029
*
@@ -63,9 +72,14 @@ public function getDir($moduleName, $type = '')
6372
$relativePath = $this->_string->upperCaseWords($moduleName, '_', '/');
6473
$path = $this->_modulesDirectory->getAbsolutePath($relativePath);
6574
}
66-
75+
6776
if ($type) {
68-
if (!in_array($type, ['etc', 'i18n', 'view', 'Controller'])) {
77+
if (!in_array($type, [
78+
self::MODULE_ETC_DIR,
79+
self::MODULE_I18N_DIR,
80+
self::MODULE_VIEW_DIR,
81+
self::MODULE_CONTROLLER_DIR
82+
])) {
6983
throw new \InvalidArgumentException("Directory type '{$type}' is not recognized.");
7084
}
7185
$path .= '/' . $type;

lib/internal/Magento/Framework/Module/ModuleRegistryInterface.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
interface ModuleRegistryInterface
1212
{
1313
/**
14-
* Get list of Magento module paths
14+
* Get list of registered Magento module paths
1515
*
1616
* Returns an array where key is fully-qualified module name and value is absolute path to module
1717
*
@@ -20,6 +20,8 @@ interface ModuleRegistryInterface
2020
public function getModulePaths();
2121

2222
/**
23+
* Get path of a module if it is already registered
24+
*
2325
* @param string $moduleName
2426
* @return null|string
2527
*/

lib/internal/Magento/Framework/Module/Registrar.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
namespace Magento\Framework\Module;
77

88
/**
9-
* Provides ability to statically register modules which do not reside in the modules directory
9+
* Provides ability to statically register modules which do not reside in the modules directory. Not all modules
10+
* will be registered by default.
1011
*
1112
* @author Josh Di Fabio <[email protected]>
1213
*/

0 commit comments

Comments
 (0)