本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Read::getRelativePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Read::getRelativePath方法的具体用法?PHP Read::getRelativePath怎么用?PHP Read::getRelativePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\Read
的用法示例。
在下文中一共展示了Read::getRelativePath方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMinifiedFile
/**
* Get path to minified file
*
* @param string $originalFile
* @return bool|string
*/
public function getMinifiedFile($originalFile)
{
if ($this->_isFileMinified($originalFile)) {
return $originalFile;
}
$originalFileRelative = $this->rootDirectory->getRelativePath($originalFile);
$minifiedFile = $this->_findOriginalMinifiedFile($originalFileRelative);
if (!$minifiedFile) {
$minifiedFile = $this->directoryName . '/' . $this->_generateMinifiedFileName($originalFile);
$this->_strategy->minifyFile($originalFileRelative, $minifiedFile);
}
$minifiedFile = $this->pubViewCacheDir->getRelativePath($minifiedFile);
return $this->pubViewCacheDir->getAbsolutePath($minifiedFile);
}
示例2: launch
/**
* Run application
*
* @return \Magento\Framework\App\ResponseInterface
* @throws \LogicException
*/
public function launch()
{
if (!$this->_mediaDirectory) {
$config = $this->_objectManager->create('Magento\\Core\\Model\\File\\Storage\\Config', ['cacheFile' => $this->_configCacheFile]);
$config->save();
$this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory());
$allowedResources = $config->getAllowedResources();
$this->_relativeFileName = str_replace($this->_mediaDirectory . '/', '', $this->_request->getPathInfo());
$isAllowed = $this->_isAllowed;
if (!$isAllowed($this->_relativeFileName, $allowedResources)) {
throw new \LogicException('The specified path is not allowed.');
}
}
if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) {
throw new \LogicException('The specified path is not within media directory.');
}
$sync = $this->_objectManager->get('Magento\\Core\\Model\\File\\Storage\\Synchronization');
$sync->synchronize($this->_relativeFileName, $this->_request->getFilePath());
if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) {
$this->_response->setFilePath($this->_request->getFilePath());
} else {
$this->_response->setHttpResponseCode(404);
}
return $this->_response;
}
示例3: _getFileData
/**
* Retrieve data from file
*
* @param string $file
* @return array
*/
protected function _getFileData($file)
{
$data = [];
if ($this->directory->isExist($this->directory->getRelativePath($file))) {
$this->_csvParser->setDelimiter(',');
$data = $this->_csvParser->getDataPairs($file);
}
return $data;
}
示例4: getComposerJsonFiles
/**
* Go through all modules and find composer.json files of active modules
*
* @return FileIterator
*/
public function getComposerJsonFiles()
{
$result = [];
foreach ($this->modulesList->getNames() as $moduleName) {
$file = $this->getModuleDir('', $moduleName) . '/composer.json';
$path = $this->modulesDirectory->getRelativePath($file);
if ($this->modulesDirectory->isExist($path)) {
$result[] = $path;
}
}
return $this->fileIteratorFactory->create($this->modulesDirectory, $result);
}
示例5: _preparePathData
/**
* Return default path related data
*
* @param string $configPath
* @return array
*/
protected function _preparePathData($configPath)
{
$themeDirectory = dirname($configPath);
if ($this->_directory->isExist($themeDirectory)) {
$fullPath = $this->_directory->getRelativePath($themeDirectory);
$pathPieces = explode('/', $fullPath);
$area = array_shift($pathPieces);
return ['area' => $area, 'theme_path_pieces' => $pathPieces];
} else {
$fullPath = $this->rootDirectory->getRelativePath($themeDirectory);
return $this->themeDirs->getAreaConfiguration($fullPath);
}
}
示例6: __construct
/**
* Open file and detect column names
*
* There must be column names in the first line
*
* @param string $file
* @param \Magento\Framework\Filesystem\Directory\Read $directory
* @param string $delimiter
* @param string $enclosure
* @throws \LogicException
*/
public function __construct($file, \Magento\Framework\Filesystem\Directory\Read $directory, $delimiter = ',', $enclosure = '"')
{
register_shutdown_function([$this, 'destruct']);
try {
$this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
} catch (\Magento\Framework\Exception\FileSystemException $e) {
throw new \LogicException("Unable to open file: '{$file}'");
}
if ($delimiter) {
$this->_delimiter = $delimiter;
}
$this->_enclosure = $enclosure;
parent::__construct($this->_getNextRow());
}
示例7: _handleInstall
/**
* Install application
*
* @param \Magento\Install\Model\Installer\Console $installer
* @return void
*/
protected function _handleInstall(\Magento\Install\Model\Installer\Console $installer)
{
if (isset($this->_arguments['config']) && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($this->_arguments['config']))) {
$config = (array) (include $this->_arguments['config']);
$this->_arguments = array_merge((array) $config, $this->_arguments);
}
$result = $installer->install($this->_arguments);
if (!$installer->hasErrors()) {
$msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : '');
$this->_output->success($msg . PHP_EOL);
} else {
$this->_output->error(implode(PHP_EOL, $installer->getErrors()) . PHP_EOL);
}
}
示例8: getActionFiles
/**
* Retrieve list of module action files
*
* @return array
*/
public function getActionFiles()
{
$actions = array();
foreach (array_keys($this->modulesList->getModules()) as $moduleName) {
$actionDir = $this->getModuleDir('Controller', $moduleName);
if (!file_exists($actionDir)) {
continue;
}
$dirIterator = new \RecursiveDirectoryIterator($actionDir, \RecursiveDirectoryIterator::SKIP_DOTS);
$recursiveIterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::LEAVES_ONLY);
/** @var \SplFileInfo $actionFile */
foreach ($recursiveIterator as $actionFile) {
$actions[] = $this->modulesDirectory->getRelativePath($actionFile->getPathname());
}
}
return $actions;
}
示例9: getCountryParams
/**
* Get Country Params by Country Code
*
* @param string $countryCode
* @return \Magento\Framework\Object
*
* @see $countryCode ISO 3166 Codes (Countries) A2
*/
protected function getCountryParams($countryCode)
{
if (empty($this->_countryParams)) {
$etcPath = $this->_configReader->getModuleDir('etc', 'Magento_Dhl');
$countriesXmlPath = $this->modulesDirectory->getRelativePath($etcPath . '/countries.xml');
$countriesXml = $this->modulesDirectory->readFile($countriesXmlPath);
$this->_countryParams = $this->_xmlElFactory->create(array('data' => $countriesXml));
}
if (isset($this->_countryParams->{$countryCode})) {
$countryParams = new \Magento\Framework\Object($this->_countryParams->{$countryCode}->asArray());
}
return isset($countryParams) ? $countryParams : new \Magento\Framework\Object();
}
示例10: _getConfigModel
/**
* Return configuration model for themes
*
* @param string $configPath
* @return \Magento\Framework\Config\Theme
*/
protected function _getConfigModel($configPath)
{
$relativeConfigPath = $this->_directory->getRelativePath($configPath);
$configContent = $this->_directory->isExist($relativeConfigPath) ? $this->_directory->readFile($relativeConfigPath) : null;
return $this->themeConfigFactory->create(['configContent' => $configContent]);
}
示例11: launch
/**
* Run application
*
* @return \Magento\Framework\App\ResponseInterface
*/
public function launch()
{
try {
if (!$this->_applicationState->isInstalled()) {
$this->_response->setHttpResponseCode(404);
return $this->_response;
}
if (!$this->_mediaDirectory) {
$config = $this->_objectManager->create('Magento\\Core\\Model\\File\\Storage\\Config', array('cacheFile' => $this->_configCacheFile));
$config->save();
$this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory());
$allowedResources = $config->getAllowedResources();
$this->_relativeFileName = str_replace($this->_mediaDirectory . '/', '', $this->_request->getPathInfo());
$isAllowed = $this->_isAllowed;
if (!$isAllowed($this->_relativeFileName, $allowedResources)) {
$this->_response->setHttpResponseCode(404);
return $this->_response;
}
}
if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) {
$this->_response->setHttpResponseCode(404);
return $this->_response;
}
$sync = $this->_objectManager->get('Magento\\Core\\Model\\File\\Storage\\Synchronization');
$sync->synchronize($this->_relativeFileName, $this->_request->getFilePath());
if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) {
$this->_response->setFilePath($this->_request->getFilePath());
} else {
$this->_response->setHttpResponseCode(404);
}
return $this->_response;
} catch (\Exception $e) {
$this->_response->setHttpResponseCode(404);
return $this->_response;
}
}
示例12: _getConfigModel
/**
* Return configuration model for themes
*
* @param string $configPath
* @return \Magento\Framework\Config\Theme
*/
protected function _getConfigModel($configPath)
{
return new \Magento\Framework\Config\Theme($this->_directory->readFile($this->_directory->getRelativePath($configPath)));
}