예제 #1
0
 public function testCollectFiles()
 {
     $componentType = 'component_type';
     $componentPaths = ['component1' => 'path1', 'component2' => 'path2'];
     $pattern = '*/file.xml';
     $this->registrar->expects($this->once())->method('getPaths')->with($componentType)->willReturn($componentPaths);
     $this->readFactory->expects($this->exactly(2))->method('create')->willReturnMap([['path1', DriverPool::FILE, $this->dir], ['path2', DriverPool::FILE, $this->dir]]);
     $this->dir->method('search')->with($pattern)->willReturnOnConsecutiveCalls(['one/file.xml'], ['two/file.xml']);
     $expected = ['one/file.xml', 'two/file.xml'];
     $this->assertSame($expected, $this->object->collectFiles($componentType, $pattern));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     switch ($scope) {
         case 'global':
             $iterator = $this->_moduleReader->getConfigurationFiles($filename);
             break;
         case 'design':
             $themePaths = $this->componentDirSearch->collectFiles(ComponentRegistrar::THEME, 'etc/' . $filename);
             $iterator = $this->iteratorFactory->create($themePaths);
             break;
         default:
             $iterator = $this->iteratorFactory->create([]);
             break;
     }
     return $iterator;
 }
예제 #3
0
 /**
  * Get paths by pattern for specified component component
  *
  * @param string $componentType
  * @param string $componentName
  * @param string $pathPattern
  * @return array
  */
 private function getPathByComponentPattern($componentType, $componentName, $pathPattern)
 {
     $files = [];
     if ($componentType == '*') {
         $componentTypes = [ComponentRegistrar::MODULE, ComponentRegistrar::LIBRARY, ComponentRegistrar::THEME, ComponentRegistrar::LANGUAGE];
     } else {
         $componentTypes = [$componentType];
     }
     foreach ($componentTypes as $type) {
         if ($componentName == '*') {
             $files = array_merge($files, $this->dirSearch->collectFiles($type, $pathPattern));
         } else {
             $componentDir = $this->componentRegistrar->getPath($type, $componentName);
             if (!empty($componentDir)) {
                 $files = array_merge($files, Glob::glob($componentDir . '/' . $pathPattern, Glob::GLOB_BRACE));
             }
         }
     }
     return $files;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     $iterator = $this->iteratorFactory->create($this->dirSearch->collectFiles(ComponentRegistrar::MODULE, 'etc/' . $filename));
     return $iterator;
 }
예제 #5
0
 /**
  * Get list of xsd files
  *
  * @param string $filename
  * @return array
  */
 public function getListXsdFiles($filename)
 {
     return $this->iteratorFactory->create(array_merge($this->componentDirSearch->collectFiles(ComponentRegistrar::MODULE, 'etc/' . $filename), $this->componentDirSearch->collectFiles(ComponentRegistrar::LIBRARY, '*/etc/' . $filename)));
 }