Пример #1
0
 /**
  * {@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);
 }
Пример #2
0
 /**
  * Test for get method with primary scope
  *
  * @dataProvider providerGet
  * @param string $filename
  * @param array $fileList
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function testGetPrimary($filename, $fileList)
 {
     $scope = 'primary';
     $directory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', ['search', 'getRelativePath'], [], '', false);
     $directory->expects($this->once())->method('search')->with(sprintf('{%1$s,*/%1$s}', $filename))->will($this->returnValue($fileList));
     $this->filesystem->expects($this->once())->method('getDirectoryRead')->with(DirectoryList::CONFIG)->will($this->returnValue($directory));
     $this->iteratorFactory->expects($this->once())->method('create')->with($directory, $fileList)->will($this->returnValue(true));
     $this->assertTrue($this->model->get($filename, $scope));
 }
Пример #3
0
 /**
  * {@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;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     switch ($scope) {
         case 'primary':
             $directory = $this->filesystem->getDirectoryRead(DirectoryList::CONFIG);
             $iterator = $this->iteratorFactory->create($directory, $directory->search('{' . $filename . ',*/' . $filename . '}'));
             break;
         case 'global':
             $iterator = $this->_moduleReader->getConfigurationFiles($filename);
             break;
         default:
             $iterator = $this->_moduleReader->getConfigurationFiles($scope . '/' . $filename);
             break;
     }
     return $iterator;
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     switch ($scope) {
         case 'global':
             $iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
             $themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
             if ($themeConfigFile && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))) {
                 $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile($this->rootDirectory->getRelativePath($themeConfigFile));
             } else {
                 $designPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $this->currentTheme);
                 if (file_exists($designPath)) {
                     try {
                         $designDom = new \DOMDocument();
                         $designDom->load($designPath);
                         $iterator[$designPath] = $designDom->saveXML();
                     } catch (\Exception $e) {
                         throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Could not read config file'));
                     }
                 }
             }
             break;
         default:
             $iterator = $this->iteratorFactory->create([]);
             break;
     }
     return $iterator;
 }
Пример #6
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;
 }
Пример #7
0
 /**
  * Go through all modules and find composer.json files of active modules
  *
  * @return FileIterator
  */
 public function getComposerJsonFiles()
 {
     $result = [];
     foreach ($this->modulesList->getNames() as $moduleName) {
         $file = $this->getModuleDir('', $moduleName) . '/composer.json';
         $path = $this->modulesDirectory->getRelativePath($file);
         if ($this->modulesDirectory->isExist($path)) {
             $result[] = $path;
         }
     }
     return $this->fileIteratorFactory->create($this->modulesDirectory, $result);
 }
Пример #8
0
 /**
  * Go through all modules and find configuration files of active modules
  *
  * @param string $filename
  * @return FileIterator
  */
 public function getConfigurationFiles($filename)
 {
     $result = array();
     foreach (array_keys($this->modulesList->getModules()) as $moduleName) {
         $file = $this->getModuleDir('etc', $moduleName) . '/' . $filename;
         $path = $this->modulesDirectory->getRelativePath($file);
         if ($this->modulesDirectory->isExist($path)) {
             $result[] = $path;
         }
     }
     return $this->fileIteratorFactory->create($this->modulesDirectory, $result);
 }
Пример #9
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function get($filename, $scope)
 {
     $moduleDir = $this->modulesDirectory->getAbsolutePath();
     $configDir = $this->configDirectory->getAbsolutePath();
     $mageScopePath = $moduleDir . '/Magento';
     $output = array('base' => array(), 'mage' => array(), 'custom' => array());
     $files = glob($moduleDir . '*/*/etc/module.xml');
     foreach ($files as $file) {
         $scope = strpos($file, $mageScopePath) === 0 ? 'mage' : 'custom';
         $output[$scope][] = $this->rootDirectory->getRelativePath($file);
     }
     $files = glob($configDir . '*/module.xml');
     foreach ($files as $file) {
         $output['base'][] = $this->rootDirectory->getRelativePath($file);
     }
     return $this->iteratorFactory->create($this->rootDirectory, array_merge($output['mage'], $output['custom'], $output['base']));
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function getParents($filename, $scope)
 {
     switch ($scope) {
         case 'global':
             $iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
             $designPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $this->currentTheme);
             if (file_exists($designPath)) {
                 try {
                     $iterator = $this->getParentConfigs($this->currentTheme, []);
                 } catch (\Exception $e) {
                     throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Could not read config file'));
                 }
             }
             break;
         default:
             $iterator = $this->iteratorFactory->create([]);
             break;
     }
     return $iterator;
 }
Пример #11
0
 /**
  * Create new instance
  *
  * @param string $type
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @param \Magento\Framework\View\Design\ThemeInterface $parentTheme
  * @param string[] $files
  * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration
  * @throws \Magento\Framework\Exception
  */
 public function create($type, \Magento\Framework\View\Design\ThemeInterface $theme = null, \Magento\Framework\View\Design\ThemeInterface $parentTheme = null, array $files = [])
 {
     $files[] = $this->_getFilePathByType($type, $theme);
     switch ($type) {
         case self::TYPE_QUICK_STYLES:
             $class = 'Magento\\DesignEditor\\Model\\Config\\Control\\QuickStyles';
             break;
         case self::TYPE_IMAGE_SIZING:
             $class = 'Magento\\DesignEditor\\Model\\Config\\Control\\ImageSizing';
             break;
         default:
             throw new \Magento\Framework\Exception("Unknown control configuration type: \"{$type}\"");
     }
     $rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
     $paths = [];
     foreach ($files as $file) {
         $paths[] = $rootDirectory->getRelativePath($file);
     }
     $fileIterator = $this->fileIteratorFactory->create($rootDirectory, $paths);
     /** @var $config \Magento\DesignEditor\Model\Config\Control\AbstractControl */
     $config = $this->_objectManager->create($class, ['configFiles' => $fileIterator]);
     return $this->_objectManager->create('Magento\\DesignEditor\\Model\\Editor\\Tools\\Controls\\Configuration', ['configuration' => $config, 'theme' => $theme, 'parentTheme' => $parentTheme]);
 }
 public function testGetDefault()
 {
     $expected = new \StdClass();
     $this->factory->expects($this->once())->method('create')->with([])->willReturn($expected);
     $this->assertSame($expected, $this->object->get('file', 'unknown'));
 }
Пример #13
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function get($filename, $scope)
 {
     return $this->iteratorFactory->create($this->configDirectory, $this->configDirectory->search('{*' . $filename . ',*/*' . $filename . '}'));
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     $iterator = $this->iteratorFactory->create($this->dirSearch->collectFiles(ComponentRegistrar::MODULE, 'etc/' . $filename));
     return $iterator;
 }
Пример #15
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     $iterator = $this->iteratorFactory->create($this->directoryRead, $this->directoryRead->search('/*/*/etc/data_source/' . $filename));
     return $iterator;
 }
Пример #16
0
 /**
  * Go through all modules and find composer.json files of active modules
  *
  * @return FileIterator
  */
 public function getComposerJsonFiles()
 {
     return $this->fileIteratorFactory->create($this->getFiles('composer.json'));
 }
Пример #17
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)));
 }