Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Module
Dir.php
Go to the documentation of this file.
1
<?php
8
namespace
Magento\Framework\Module
;
9
10
use
Magento\Framework\Component\ComponentRegistrar
;
11
use
Magento\Framework\Component\ComponentRegistrarInterface
;
12
13
class
Dir
14
{
18
const
MODULE_ETC_DIR
=
'etc'
;
19
const
MODULE_I18N_DIR
=
'i18n'
;
20
const
MODULE_VIEW_DIR
=
'view'
;
21
const
MODULE_CONTROLLER_DIR
=
'Controller'
;
22
const
MODULE_SETUP_DIR
=
'Setup'
;
26
private
$componentRegistrar;
27
31
public
function
__construct
(
ComponentRegistrarInterface
$componentRegistrar)
32
{
33
$this->componentRegistrar =
$componentRegistrar
;
34
}
35
44
public
function
getDir
($moduleName,
$type
=
''
)
45
{
46
$path
= $this->componentRegistrar->getPath(
ComponentRegistrar::MODULE
, $moduleName);
47
48
// An empty $type means it's getting the directory of the module itself.
49
if
(empty(
$type
) && !isset(
$path
)) {
50
// Note: do not throw \LogicException, as it would break backwards-compatibility.
51
throw
new \InvalidArgumentException(
"Module '$moduleName' is not correctly registered."
);
52
}
53
54
if
(
$type
) {
55
if
(!in_array(
$type
, [
56
self::MODULE_ETC_DIR,
57
self::MODULE_I18N_DIR,
58
self::MODULE_VIEW_DIR,
59
self::MODULE_CONTROLLER_DIR,
60
self::MODULE_SETUP_DIR
61
])) {
62
throw
new \InvalidArgumentException(
"Directory type '{$type}' is not recognized."
);
63
}
64
$path
.=
'/'
.
$type
;
65
}
66
67
return
$path
;
68
}
69
}
Magento\Framework\Module\Dir\MODULE_ETC_DIR
const MODULE_ETC_DIR
Definition:
Dir.php:18
$componentRegistrar
$componentRegistrar
Definition:
bootstrap.php:23
Magento\Framework\Module\Dir\MODULE_SETUP_DIR
const MODULE_SETUP_DIR
Definition:
Dir.php:22
Magento\Framework\Module\Dir\MODULE_I18N_DIR
const MODULE_I18N_DIR
Definition:
Dir.php:19
Magento\Framework\Module\Dir\getDir
getDir($moduleName, $type='')
Definition:
Dir.php:44
$type
$type
Definition:
item.phtml:13
Magento\Framework\Module
Definition:
ConflictChecker.php:6
Magento\Framework\Module\Dir\MODULE_CONTROLLER_DIR
const MODULE_CONTROLLER_DIR
Definition:
Dir.php:21
Magento\Framework\Component\ComponentRegistrar\MODULE
const MODULE
Definition:
ComponentRegistrar.php:21
Magento\Framework\Module\Dir\__construct
__construct(ComponentRegistrarInterface $componentRegistrar)
Definition:
Dir.php:31
Magento\Framework\Module\Dir\MODULE_VIEW_DIR
const MODULE_VIEW_DIR
Definition:
Dir.php:20
Magento\Framework\Component\ComponentRegistrarInterface
Definition:
ComponentRegistrarInterface.php:11
Magento\Framework\Component\ComponentRegistrar
Definition:
ComponentRegistrar.php:16
Magento\Framework\Module\Dir
Definition:
Dir.php:13
$path
$path
Definition:
import_with_filesystem_images.php:14