本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\ReadInterface::read方法的典型用法代码示例。如果您正苦于以下问题:PHP ReadInterface::read方法的具体用法?PHP ReadInterface::read怎么用?PHP ReadInterface::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\ReadInterface
的用法示例。
在下文中一共展示了ReadInterface::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _findFirstFileRelativePath
/**
* Find a relative path to a first file located in a directory or its descendants
*
* @param string $dir Directory to search for a file within
* @param string $pattern PCRE pattern a file name has to match
* @return string|null
*/
protected function _findFirstFileRelativePath($dir, $pattern = '/.*/')
{
$childDirs = array();
foreach ($this->_pubDirectory->read($dir) as $itemPath) {
if ($this->_pubDirectory->isFile($itemPath)) {
if (preg_match($pattern, $itemPath)) {
return $itemPath;
}
} else {
$childDirs[$itemPath] = $itemPath;
}
}
foreach ($childDirs as $dirName => $dirPath) {
$filePath = $this->_findFirstFileRelativePath($dirPath, $pattern);
if ($filePath) {
return $filePath;
}
}
return null;
}
示例2: _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);
}