本文整理匯總了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);
}