本文整理汇总了PHP中Magento\Framework\Module\Dir\Reader::getModuleDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::getModuleDir方法的具体用法?PHP Reader::getModuleDir怎么用?PHP Reader::getModuleDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Module\Dir\Reader
的用法示例。
在下文中一共展示了Reader::getModuleDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param \Magento\Framework\Module\Dir\Reader $modulesReader
* @param \Magento\Framework\Config\DomFactory $domConfigFactory
*/
public function __construct(\Magento\Framework\Module\Dir\Reader $modulesReader, \Magento\Framework\Config\DomFactory $domConfigFactory)
{
$this->_modulesReader = $modulesReader;
$this->_domConfigFactory = $domConfigFactory;
$this->_initMessageTemplates();
$this->_xsdSchemas = array(self::LAYOUT_SCHEMA_SINGLE_HANDLE => $this->_modulesReader->getModuleDir('etc', 'Magento_Core') . '/layout_single.xsd', self::LAYOUT_SCHEMA_MERGED => $this->_modulesReader->getModuleDir('etc', 'Magento_Core') . '/layout_merged.xsd');
}
示例2: testGetModuleDirWhenCustomDirIsSet
public function testGetModuleDirWhenCustomDirIsSet()
{
$moduleDir = 'app/code/Test/Module/etc/custom';
$this->_dirsMock->expects($this->never())->method('getDir');
$this->_model->setModuleDir('Test_Module', 'etc', $moduleDir);
$this->assertEquals($moduleDir, $this->_model->getModuleDir(Dir::MODULE_ETC_DIR, 'Test_Module'));
}
示例3: __construct
/**
* constructor
*
* @param \Magento\Framework\Module\Dir\Reader $moduleReader
* @param $fileSchema
* @param null $mergedSchema
*/
public function __construct(Reader $moduleReader, $fileSchema, $mergedSchema = null)
{
if (is_null($mergedSchema)) {
$mergedSchema = $fileSchema . '_merged';
}
$this->schema = $moduleReader->getModuleDir('etc', 'Umc_Base') . '/umc/' . $mergedSchema . '.xsd';
$this->perFileSchema = $moduleReader->getModuleDir('etc', 'Umc_Base') . '/umc/' . $fileSchema . '.xsd';
}
示例4: hasLocalCopy
/**
* @return bool
*/
public function hasLocalCopy()
{
$path = $this->_moduleReader->getModuleDir('etc', 'Magento_Adminhtml');
$directory = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MODULES_DIR);
if ($path && $directory->isDirectory($directory->getRelativePath($path))) {
return true;
}
return false;
}
示例5: __construct
/**
* Read locales
* @param \Magento\Framework\Module\Dir\Reader $moduleReader
*/
public function __construct(\Magento\Framework\Module\Dir\Reader $moduleReader)
{
$file = $moduleReader->getModuleDir('etc', 'BelVG_FacebookFree') . '/' . 'locale.xml';
if (is_readable($file)) {
$this->locales = simplexml_load_file($file);
}
}
示例6: __construct
/**
* Build DOM with initial XML contents and specifying identifier attributes for merging
*
* Format of $schemaFileType: array('etc', 'sql', 'data', 'i18n', 'view', 'Controller')
* Format of $schemaFileModule: 'Magento_XXXXX'
* Format of $schemaFileName: 'schema.xsd'
* Format of $idAttributes: array('name', 'id')
* Format of $contextXPath: array('/config/ui')
* The path to ID attribute name should not include any attribute notations or modifiers -- only node names
*
* @param string $schemaFileType
* @param string $schemaFileModule
* @param string $schemaFileName
* @param DirectoryReader $directoryReader
* @param bool $isMergeSimpleXMLElement
* @param array $contextXPath
* @param array $idAttributes
*/
public function __construct(DirectoryReader $directoryReader, $schemaFileType, $schemaFileModule, $schemaFileName, $isMergeSimpleXMLElement = false, array $contextXPath = [], array $idAttributes = [])
{
$this->schemaFilePath = $directoryReader->getModuleDir($schemaFileType, $schemaFileModule) . '/' . trim($schemaFileName, '/');
$this->isMergeSimpleXMLElement = $isMergeSimpleXMLElement;
$this->contextXPath = $contextXPath;
$this->idAttributes = $idAttributes;
}
示例7: getVclFile
/**
* Return generated varnish.vcl configuration file
*
* @param string $vclTemplatePath
* @return string
* @api
*/
public function getVclFile($vclTemplatePath)
{
$moduleEtcPath = $this->reader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_PageCache');
$configFilePath = $moduleEtcPath . '/' . $this->_scopeConfig->getValue($vclTemplatePath);
$directoryRead = $this->readFactory->create($moduleEtcPath);
$configFilePath = $directoryRead->getRelativePath($configFilePath);
$data = $directoryRead->readFile($configFilePath);
return strtr($data, $this->_getReplacements());
}
示例8: getContent
/**
* Get content of include file (in adminhtml area)
*
* @param string $includePath
* @return string
* @throws LocalizedException
*/
protected function getContent($includePath)
{
// <include path="Magento_Payment::my_payment.xml" />
list($moduleName, $filename) = explode('::', $includePath);
$path = 'adminhtml/' . $filename;
$directoryRead = $this->readFactory->create($this->moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, $moduleName));
if ($directoryRead->isExist($path) && $directoryRead->isFile($path)) {
return $directoryRead->readFile($path);
}
throw new LocalizedException(__('The file "%1" does not exist', $path));
}
示例9: execute
/**
* Download sample file action
*
* @return \Magento\Framework\Controller\Result\Raw
*/
public function execute()
{
$fileName = $this->getRequest()->getParam('filename') . '.csv';
$moduleDir = $this->reader->getModuleDir('', self::SAMPLE_FILES_MODULE);
$fileAbsolutePath = $moduleDir . '/' . $fileName;
$directoryRead = $this->readFactory->create($moduleDir);
$filePath = $directoryRead->getRelativePath($fileAbsolutePath);
if (!$directoryRead->isFile($filePath)) {
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->messageManager->addError(__('There is no sample file for this entity.'));
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('*/import');
return $resultRedirect;
}
$fileSize = isset($directoryRead->stat($filePath)['size']) ? $directoryRead->stat($filePath)['size'] : null;
$this->fileFactory->create($fileName, null, DirectoryList::VAR_DIR, 'application/octet-stream', $fileSize);
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
$resultRaw->setContents($directoryRead->readFile($filePath));
return $resultRaw;
}
示例10: getContent
/**
* Get content include file (in adminhtml area)
*
* @param string $includePath
* @return string
* @throws LocalizedException
*/
protected function getContent($includePath)
{
$modulesDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MODULES);
// <include path="Magento_Payment::my_payment.xml" />
list($moduleName, $filename) = explode('::', $includePath);
$file = $this->moduleReader->getModuleDir('etc', $moduleName) . '/adminhtml/' . $filename;
$path = $modulesDirectory->getRelativePath($file);
if ($modulesDirectory->isExist($path) && $modulesDirectory->isFile($path)) {
return $modulesDirectory->readFile($path);
}
throw new LocalizedException(__('The file "' . $path . '" does not exist'));
}
示例11: __construct
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Module\Dir\Reader $configReader, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Mehulchaudhari\Geoip\Helper\Data $geoipHelper, array $data = [])
{
$this->_geoipHelper = $geoipHelper;
$this->_logger = $context->getLogger();
$this->_scopeConfig = $scopeConfig;
$this->_storeManager = $storeManager;
$this->libpath = $configReader->getModuleDir('', 'Mehulchaudhari_Geoip');
if (!function_exists('geoip_country_code_by_name') && $this->_geoipHelper->getConfig('general/apache_or_file') == 1) {
define('GEOIP_LOCAL', 1);
$geoIpInc = $this->libpath . '/lib/geoip.inc';
include $geoIpInc;
}
}
示例12: _getConfigDomXPath
/**
* Get persistent XML config xpath
*
* @return \DOMXPath
* @throws \Magento\Framework\Model\Exception
*/
protected function _getConfigDomXPath()
{
if (is_null($this->_configDomXPath)) {
$filePath = $this->_modulesDirectory->getRelativePath($this->_configFilePath);
$isFile = $this->_modulesDirectory->isFile($filePath);
$isReadable = $this->_modulesDirectory->isReadable($filePath);
if (!$isFile || !$isReadable) {
throw new \Magento\Framework\Model\Exception(__('We cannot load the configuration from file %1.', $this->_configFilePath));
}
$xml = $this->_modulesDirectory->readFile($filePath);
/** @var \Magento\Framework\Config\Dom $configDom */
$configDom = $this->_domFactory->createDom(array('xml' => $xml, 'idAttributes' => array('config/instances/blocks/reference' => 'id'), 'schemaFile' => $this->_moduleReader->getModuleDir('etc', 'Magento_Persistent') . '/persistent.xsd'));
$this->_configDomXPath = new \DOMXPath($configDom->getDom());
}
return $this->_configDomXPath;
}
示例13: _construct
/**
* Internal constructor
*
* @return void
*/
protected function _construct()
{
parent::_construct();
$paymentCode = $this->_getCheckout()->getQuote()->getPayment()->getMethod();
if (in_array($paymentCode, $this->_hssHelper->getHssMethods())) {
$this->_paymentMethodCode = $paymentCode;
$templatePath = str_replace('_', '', $paymentCode);
$templateFile = "{$templatePath}/iframe.phtml";
$directory = $this->readFactory->create($this->reader->getModuleDir('', 'Magento_Paypal'));
$file = $this->resolver->getTemplateFileName($templateFile, ['module' => 'Magento_Paypal']);
if ($file && $directory->isExist($directory->getRelativePath($file))) {
$this->setTemplate($templateFile);
} else {
$this->setTemplate('hss/iframe.phtml');
}
}
}
示例14: _getAvailableDataFiles
/**
* Retrieve available Data install/upgrade files for current module
*
* @param string $actionType
* @param string $fromVersion
* @param string $toVersion
* @return array
*/
protected function _getAvailableDataFiles($actionType, $fromVersion, $toVersion)
{
$modName = (string) $this->_moduleConfig['name'];
$files = [];
$filesDir = $this->_modulesReader->getModuleDir('data', $modName) . '/' . $this->_resourceName;
$modulesDirPath = $this->modulesDir->getRelativePath($filesDir);
if ($this->modulesDir->isDirectory($modulesDirPath) && $this->modulesDir->isReadable($modulesDirPath)) {
$regExp = sprintf('#%s-(.*)\\.php$#i', $actionType);
foreach ($this->modulesDir->read($modulesDirPath) as $file) {
$matches = [];
if (preg_match($regExp, $file, $matches)) {
$files[$matches[1]] = $this->modulesDir->getAbsolutePath($file);
}
}
}
if (empty($files)) {
return [];
}
return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $files);
}
示例15: _getConfigDomXPath
/**
* Get persistent XML config xpath
*
* @return \DOMXPath
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _getConfigDomXPath()
{
if ($this->_configDomXPath === null) {
$dir = explode("/", $this->_configFilePath);
array_pop($dir);
$dir = implode("/", $dir);
$directoryRead = $this->readFactory->create($dir);
$filePath = $directoryRead->getRelativePath($this->_configFilePath);
$isFile = $directoryRead->isFile($filePath);
$isReadable = $directoryRead->isReadable($filePath);
if (!$isFile || !$isReadable) {
throw new \Magento\Framework\Exception\LocalizedException(__('We cannot load the configuration from file %1.', $this->_configFilePath));
}
$xml = $directoryRead->readFile($filePath);
/** @var \Magento\Framework\Config\Dom $configDom */
$configDom = $this->_domFactory->createDom(['xml' => $xml, 'idAttributes' => ['config/instances/blocks/reference' => 'id'], 'schemaFile' => $this->_moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_Persistent') . '/persistent.xsd']);
$this->_configDomXPath = new \DOMXPath($configDom->getDom());
}
return $this->_configDomXPath;
}