Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileResolverByModule.php
Go to the documentation of this file.
1 <?php
7 
12 
16 class FileResolverByModule extends \Magento\Framework\App\Config\FileResolver
17 {
21  const ALL_MODULES = 'all';
22 
26  private $componentRegistrar;
27 
31  private $driver;
32 
42  public function __construct(
43  \Magento\Framework\Module\Dir\Reader $moduleReader,
44  \Magento\Framework\Filesystem $filesystem,
46  ComponentRegistrar $componentRegistrar,
47  \Magento\Framework\Filesystem\Driver\File $driver
48  ) {
49  parent::__construct($moduleReader, $filesystem, $iteratorFactory);
50  $this->componentRegistrar = $componentRegistrar;
51  $this->driver = $driver;
52  }
53 
59  public function get($filename, $scope)
60  {
61  $iterator = $this->_moduleReader->getConfigurationFiles($filename)->toArray();
62  if ($scope !== self::ALL_MODULES) {
63  $path = $this->componentRegistrar->getPath('module', $scope);
64  $path .= '/' . Dir::MODULE_ETC_DIR . '/'. $filename;
65  $iterator = isset($iterator[$path]) ? [$path => $iterator[$path]] : [];
66  }
67  $primaryFile = parent::get($filename, 'primary')->toArray();
68  if (!$this->driver->isFile(key($primaryFile))) {
69  throw new \Exception("Primary db_schema file doesn`t exists");
70  }
72  $iterator += $primaryFile;
73  return $iterator;
74  }
75 }
$componentRegistrar
Definition: bootstrap.php:23
__construct(\Magento\Framework\Module\Dir\Reader $moduleReader, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Config\FileIteratorFactory $iteratorFactory, ComponentRegistrar $componentRegistrar, \Magento\Framework\Filesystem\Driver\File $driver)