当前位置: 首页>>代码示例>>PHP>>正文


PHP ReadInterface::search方法代码示例

本文整理汇总了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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:38,代码来源:ThemeModular.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:35,代码来源:Base.php

示例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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Primary.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Theme.php

示例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();
 }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例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();
 }
开发者ID:vrann,项目名称:magento2-from-vendor,代码行数:20,代码来源:Library.php

示例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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:FileResolver.php

示例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();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Library.php

示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:26,代码来源:Config.php

示例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;
 }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例11: get

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function get($filename, $scope)
 {
     return $this->iteratorFactory->create($this->configDirectory, $this->configDirectory->search('{*' . $filename . ',*/*' . $filename . '}'));
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:8,代码来源:Primary.php

示例12: get

 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     $iterator = $this->iteratorFactory->create($this->directoryRead, $this->directoryRead->search('/*/*/etc/data_source/' . $filename));
     return $iterator;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:8,代码来源:FileResolver.php


注:本文中的Magento\Framework\Filesystem\Directory\ReadInterface::search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。