本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\ReadInterface::search方法的典型用法代码示例。如果您正苦于以下问题:PHP ReadInterface::search方法的具体用法?PHP ReadInterface::search怎么用?PHP ReadInterface::search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\ReadInterface
的用法示例。
在下文中一共展示了ReadInterface::search方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例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: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$list = $this->fileListFactory->create();
$files = $this->libraryDirectory->search($filePath);
$list->add($this->createFiles($this->libraryDirectory, $theme, $files));
foreach ($theme->getInheritedThemes() as $currentTheme) {
$themeFullPath = $currentTheme->getFullPath();
$files = $this->themesDirectory->search("{$themeFullPath}/web/{$filePath}");
$list->replace($this->createFiles($this->themesDirectory, $theme, $files), false);
}
return $list->getAll();
}
示例6: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$list = $this->fileListFactory->create('Magento\\Framework\\Less\\File\\FileList\\Collator');
$files = $this->libraryDirectory->search($filePath);
$list->add($this->createFiles($this->libraryDirectory, $theme, $files));
foreach ($theme->getInheritedThemes() as $currentTheme) {
$themeFullPath = $currentTheme->getFullPath();
$files = $this->rootDirectory->search("web/{$filePath}", $this->themeDir->getPathByKey($themeFullPath));
//$files = $this->themesDirectory->search("{$themeFullPath}/web/{$filePath}");
$list->replace($this->createFiles($this->themesDirectory, $theme, $files), false);
}
return $list->getAll();
}
示例7: get
/**
* {@inheritdoc}
*/
public function get($filename, $scope)
{
switch ($scope) {
case 'global':
$iterator = $this->_moduleReader->getConfigurationFiles($filename);
break;
case 'design':
$iterator = $this->iteratorFactory->create($this->themesDirectory, $this->themesDirectory->search('/*/*/etc/' . $filename));
break;
default:
$iterator = $this->iteratorFactory->create($this->themesDirectory, array());
break;
}
return $iterator;
}
示例8: getFiles
/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param string $filePath
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$list = $this->fileListFactory->create('Magento\\Framework\\Css\\PreProcessor\\File\\FileList\\Collator');
$files = $this->libraryDirectory->search($filePath);
$list->add($this->createFiles($this->libraryDirectory, $theme, $files));
foreach ($theme->getInheritedThemes() as $currentTheme) {
$themeFullPath = $currentTheme->getFullPath();
$path = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themeFullPath);
if (empty($path)) {
continue;
}
$directoryRead = $this->readFactory->create($path);
$foundFiles = $directoryRead->search("web/{$filePath}");
$list->replace($this->createFiles($directoryRead, $theme, $foundFiles));
}
return $list->getAll();
}
示例9: getThemeTemplates
/**
* Find all theme-based email templates for a given template ID
*
* @param string $templateId
* @return array[]
*/
public function getThemeTemplates($templateId)
{
$templates = [];
$area = $this->getTemplateArea($templateId);
$themePath = '*/*';
$module = $this->getTemplateModule($templateId);
$filename = $this->_getInfo($templateId, 'file');
$searchPattern = "{$area}/{$themePath}/{$module}/email/{$filename}";
$files = $this->themesDirectory->search($searchPattern);
$pattern = "#^(?<area>[^/]+)/(?<themeVendor>[^/]+)/(?<themeName>[^/]+)/#i";
foreach ($files as $file) {
if (!preg_match($pattern, $file, $matches)) {
continue;
}
$themeVendor = $matches['themeVendor'];
$themeName = $matches['themeName'];
$templates[] = ['value' => sprintf('%s/%s/%s', $templateId, $themeVendor, $themeName), 'label' => sprintf('%s (%s/%s)', $this->getTemplateLabel($templateId), $themeVendor, $themeName), 'group' => $this->getTemplateModule($templateId)];
}
return $templates;
}
示例10: readPackCsv
/**
* Read the CSV-files in a language package
*
* The files are sorted alphabetically, then each of them is read, and results are recorded into key => value array
*
* @param string $vendor
* @param string $package
* @return array
*/
private function readPackCsv($vendor, $package)
{
$files = $this->dir->search("{$vendor}/{$package}/*.csv");
sort($files);
$result = [];
foreach ($files as $path) {
$file = $this->dir->openFile($path);
while (($row = $file->readCsv()) !== false) {
$result[$row[0]] = $row[1];
}
}
return $result;
}
示例11: get
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function get($filename, $scope)
{
return $this->iteratorFactory->create($this->configDirectory, $this->configDirectory->search('{*' . $filename . ',*/*' . $filename . '}'));
}
示例12: get
/**
* {@inheritdoc}
*/
public function get($filename, $scope)
{
$iterator = $this->iteratorFactory->create($this->directoryRead, $this->directoryRead->search('/*/*/etc/data_source/' . $filename));
return $iterator;
}