Exemple #1
0
 /**
  * Retrieve the list of configuration files with given name that relate to specified scope
  *
  * @param string $filename
  * @param string $scope
  * @return array|\Iterator,\Countable
  */
 public function get($filename, $scope)
 {
     $modulesPath = $this->moduleResolver->getModulesPath();
     $paths = [];
     foreach ($modulesPath as $modulePath) {
         $path = $modulePath . '/Test/' . $scope . '/' . $filename;
         if (is_readable($path)) {
             $paths[] = $path;
         }
     }
     $iterator = new File($paths);
     return $iterator;
 }
Exemple #2
0
 /**
  * Collect all xml pages
  *
  * @return array
  */
 protected function collectPagesXml()
 {
     $items = [];
     $modules = $this->moduleResolver->getModulesPath();
     foreach ($modules as $modulePath) {
         $modulePathArray = explode('/', $modulePath);
         $module = array_pop($modulePathArray);
         if (!is_readable($modulePath . '/Test/Page')) {
             continue;
         }
         $dirIterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($modulePath . '/Test/Page', \FilesystemIterator::SKIP_DOTS)), '/.xml$/i');
         foreach ($dirIterator as $fileInfo) {
             /** @var $fileInfo \SplFileInfo */
             $fileName = $fileInfo->getBasename('.xml');
             $modulePath = str_replace('\\', '/', $modulePath);
             $folderPath = str_replace('\\', '/', $fileInfo->getPath());
             $area = trim(str_replace($modulePath . '/Test/Page', '', $folderPath), '/');
             $key = ($area ? "{$area}_" : '') . $fileName;
             $items[$key][] = ['file_name' => $fileName, 'area' => $area, 'real_path' => str_replace('\\', '/', $fileInfo->getRealPath()), 'module' => $module];
         }
     }
     return $items;
 }