當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。