本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\ReadInterface::getAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:PHP ReadInterface::getAbsolutePath方法的具体用法?PHP ReadInterface::getAbsolutePath怎么用?PHP ReadInterface::getAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\ReadInterface
的用法示例。
在下文中一共展示了ReadInterface::getAbsolutePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$result = [];
$namespace = $module = '*';
$sharedFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/base/{$this->subDir}{$filePath}");
$filePathPtn = strtr(preg_quote($filePath), ['\\*' => '[^/]+']);
$pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/base/{$this->subDir}" . $filePathPtn . "\$#i";
foreach ($sharedFiles as $file) {
$filename = $this->modulesDirectory->getAbsolutePath($file);
if (!preg_match($pattern, $filename, $matches)) {
continue;
}
$moduleFull = "{$matches['namespace']}_{$matches['module']}";
$result[] = $this->fileFactory->create($filename, $moduleFull, null, true);
}
$area = $theme->getData('area');
$themeFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/{$area}/{$this->subDir}{$filePath}");
$pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/{$area}/{$this->subDir}" . $filePathPtn . "\$#i";
foreach ($themeFiles as $file) {
$filename = $this->modulesDirectory->getAbsolutePath($file);
if (!preg_match($pattern, $filename, $matches)) {
continue;
}
$moduleFull = "{$matches['namespace']}_{$matches['module']}";
$result[] = $this->fileFactory->create($filename, $moduleFull);
}
return $result;
}
示例2: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
* @throws \Magento\Framework\Exception
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$namespace = $module = '*';
$themePath = $theme->getFullPath();
$searchPattern = "{$themePath}/{$namespace}_{$module}/{$this->subDir}*/*/{$filePath}";
$files = $this->themesDirectory->search($searchPattern);
if (empty($files)) {
return [];
}
$themes = [];
$currentTheme = $theme;
while ($currentTheme = $currentTheme->getParentTheme()) {
$themes[$currentTheme->getCode()] = $currentTheme;
}
$result = [];
$pattern = "#/(?<module>[^/]+)/{$this->subDir}(?<themeVendor>[^/]+)/(?<themeName>[^/]+)/" . strtr(preg_quote($filePath), ['\\*' => '[^/]+']) . "\$#i";
foreach ($files as $file) {
$filename = $this->themesDirectory->getAbsolutePath($file);
if (!preg_match($pattern, $filename, $matches)) {
continue;
}
$moduleFull = $matches['module'];
$ancestorThemeCode = $matches['themeVendor'] . '/' . $matches['themeName'];
if (!isset($themes[$ancestorThemeCode])) {
throw new Exception(sprintf("Trying to override modular view file '%s' for theme '%s', which is not ancestor of theme '%s'", $filename, $ancestorThemeCode, $theme->getCode()));
}
$result[] = $this->fileFactory->create($filename, $moduleFull, $themes[$ancestorThemeCode]);
}
return $result;
}
示例3: get
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function get($filename, $scope)
{
$configPaths = $this->configDirectory->search('{*' . $filename . ',*/*' . $filename . '}');
$configAbsolutePaths = [];
foreach ($configPaths as $configPath) {
$configAbsolutePaths[] = $this->configDirectory->getAbsolutePath($configPath);
}
return $this->iteratorFactory->create($configAbsolutePaths);
}
示例4: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$themePath = $theme->getFullPath();
$files = $this->themesDirectory->search("{$themePath}/{$this->subDir}{$filePath}");
$result = [];
foreach ($files as $file) {
$filename = $this->themesDirectory->getAbsolutePath($file);
$result[] = $this->fileFactory->create($filename, null, $theme);
}
return $result;
}
示例5: getDir
/**
* Retrieve full path to a directory of certain type within a module
*
* @param string $moduleName Fully-qualified module name
* @param string $type Type of module's directory to retrieve
* @return string
* @throws \InvalidArgumentException
*/
public function getDir($moduleName, $type = '')
{
$path = $this->_string->upperCaseWords($moduleName, '_', '/');
if ($type) {
if (!in_array($type, array('etc', 'sql', 'data', 'i18n', 'view', 'Controller'))) {
throw new \InvalidArgumentException("Directory type '{$type}' is not recognized.");
}
$path .= '/' . $type;
}
$result = $this->_modulesDirectory->getAbsolutePath($path);
return $result;
}
示例6: getDir
/**
* Retrieve full path to a directory of certain type within a module
*
* @param string $moduleName Fully-qualified module name
* @param string $type Type of module's directory to retrieve
* @return string
* @throws \InvalidArgumentException
*/
public function getDir($moduleName, $type = '')
{
if (null === ($path = $this->moduleRegistry->getModulePath($moduleName))) {
$relativePath = $this->_string->upperCaseWords($moduleName, '_', '/');
$path = $this->_modulesDirectory->getAbsolutePath($relativePath);
}
if ($type) {
if (!in_array($type, [self::MODULE_ETC_DIR, self::MODULE_I18N_DIR, self::MODULE_VIEW_DIR, self::MODULE_CONTROLLER_DIR])) {
throw new \InvalidArgumentException("Directory type '{$type}' is not recognized.");
}
$path .= '/' . $type;
}
return $path;
}
示例7: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$namespace = $module = '*';
$themePath = $theme->getFullPath();
$files = $this->themesDirectory->search("{$themePath}/{$namespace}_{$module}/{$this->subDir}{$filePath}");
$result = array();
$pattern = "#/(?<moduleName>[^/]+)/{$this->subDir}" . strtr(preg_quote($filePath), array('\\*' => '[^/]+')) . "\$#i";
foreach ($files as $file) {
$filename = $this->themesDirectory->getAbsolutePath($file);
if (!preg_match($pattern, $filename, $matches)) {
continue;
}
$result[] = $this->fileFactory->create($filename, $matches['moduleName'], $theme);
}
return $result;
}
示例8: preProcess
/**
* Perform necessary preprocessing and materialization when the specified asset is requested
*
* Returns an array of two elements:
* - directory where the file is supposed to be found
* - relative path to the file
*
* returns false if source file was not found
*
* @param LocalInterface $asset
* @return array|bool
*/
private function preProcess(LocalInterface $asset)
{
$sourceFile = $this->findSourceFile($asset);
$dir = $this->rootDir->getAbsolutePath();
$path = '';
if ($sourceFile) {
$path = basename($sourceFile);
$dir = dirname($sourceFile);
}
$chain = $this->createChain($asset, $dir, $path);
$this->preProcessorPool->process($chain);
$chain->assertValid();
if ($chain->isChanged()) {
$dir = $this->varDir->getAbsolutePath();
$path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
$this->varDir->writeFile($path, $chain->getContent());
}
if (empty($path)) {
$result = false;
} else {
$result = [$dir, $path];
}
return $result;
}
示例9: getFiles
/**
* Get layout files from modules, theme with ancestors and library
*
* @param ThemeInterface $theme
* @param string $filePath
* @throws \InvalidArgumentException
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
if (empty($filePath)) {
throw new \InvalidArgumentException('File path must be specified');
}
$files = [];
if ($this->libDirectory->isExist($filePath)) {
$filename = $this->libDirectory->getAbsolutePath($filePath);
$files[] = $this->fileFactory->create($filename);
}
$files = array_merge($files, $this->baseFiles->getFiles($theme, $filePath));
foreach ($theme->getInheritedThemes() as $currentTheme) {
$files = array_merge($files, $this->themeModularFiles->getFiles($currentTheme, $filePath));
$files = array_merge($files, $this->themeFiles->getFiles($currentTheme, $filePath));
}
return $files;
}
示例10: get
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function get($filename, $scope)
{
$moduleDir = $this->modulesDirectory->getAbsolutePath();
$configDir = $this->configDirectory->getAbsolutePath();
$mageScopePath = $moduleDir . '/Magento';
$output = array('base' => array(), 'mage' => array(), 'custom' => array());
$files = glob($moduleDir . '*/*/etc/module.xml');
foreach ($files as $file) {
$scope = strpos($file, $mageScopePath) === 0 ? 'mage' : 'custom';
$output[$scope][] = $this->rootDirectory->getRelativePath($file);
}
$files = glob($configDir . '*/module.xml');
foreach ($files as $file) {
$output['base'][] = $this->rootDirectory->getRelativePath($file);
}
return $this->iteratorFactory->create($this->rootDirectory, array_merge($output['mage'], $output['custom'], $output['base']));
}
示例11: createFiles
/**
* @param ReadInterface $reader
* @param ThemeInterface $theme
* @param array $files
* @return array
*/
protected function createFiles(ReadInterface $reader, ThemeInterface $theme, $files)
{
$result = [];
foreach ($files as $file) {
$filename = $reader->getAbsolutePath($file);
$result[] = $this->fileFactory->create($filename, false, $theme);
}
return $result;
}
示例12: fillPropertiesByMinifyingAsset
/**
* Generate minified file and fill the properties to reference that file
*
* @return void
*/
protected function fillPropertiesByMinifyingAsset()
{
$path = $this->originalAsset->getPath();
$this->context = new \Magento\Framework\View\Asset\File\Context($this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_STATIC]), DirectoryList::STATIC_VIEW, self::CACHE_VIEW_REL . '/minified');
$this->filePath = md5($path) . '_' . $this->composeMinifiedName(basename($path));
$this->path = $this->context->getPath() . '/' . $this->filePath;
$this->minify();
$this->file = $this->staticViewDir->getAbsolutePath($this->path);
$this->url = $this->context->getBaseUrl() . $this->path;
}
示例13: resolve
/**
* {@inheritdoc}
*/
public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
{
self::assertFilePathFormat($file);
$themePath = $theme ? $theme->getThemePath() : '';
$path = $this->cache->getFromCache($type, $file, $area, $themePath, $locale, $module);
if (false !== $path) {
$path = $path ? $this->rootDirectory->getAbsolutePath($path) : false;
} else {
$params = ['area' => $area, 'theme' => $theme, 'locale' => $locale];
foreach ($params as $key => $param) {
if ($param === null) {
unset($params[$key]);
}
}
if (!empty($module)) {
list($params['namespace'], $params['module']) = explode('_', $module, 2);
}
$path = $this->resolveFile($this->rulePool->getRule($type), $file, $params);
$cachedValue = $path ? $this->rootDirectory->getRelativePath($path) : '';
$this->cache->saveToCache($cachedValue, $type, $file, $area, $themePath, $locale, $module);
}
return $path;
}
示例14: copyQuoteToOrder
/**
* Quote item to order item copy process
*
* @return $this
*/
public function copyQuoteToOrder()
{
$quoteOption = $this->getConfigurationItemOption();
try {
$value = unserialize($quoteOption->getValue());
if (!isset($value['quote_path'])) {
throw new \Exception();
}
$quotePath = $value['quote_path'];
$orderPath = $value['order_path'];
if (!$this->_rootDirectory->isFile($quotePath) || !$this->_rootDirectory->isReadable($quotePath)) {
throw new \Exception();
}
$this->_coreFileStorageDatabase->copyFile($this->_rootDirectory->getAbsolutePath($quotePath), $this->_rootDirectory->getAbsolutePath($orderPath));
} catch (\Exception $e) {
return $this;
}
return $this;
}
示例15: _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);
}