コード例 #1
0
ファイル: Config.php プロジェクト: aiesh/magento2
 /**
  * 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
0
 /**
  * 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);
 }