Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FixtureConfig.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Setup\Fixtures;
8 
10 
15 {
19  private $config;
20 
24  private $parser;
25 
29  public function __construct(Parser $parser)
30  {
31  $this->parser = $parser;
32  }
33 
42  public function loadConfig($filename)
43  {
44  if (!is_readable($filename)) {
45  throw new \Exception("Profile configuration file `{$filename}` is not readable or does not exists.");
46  }
47  $this->parser->getDom()->load($filename);
48  $this->parser->getDom()->xinclude();
49  $this->config = $this->parser->xmlToArray();
50  $this->config['config']['profile']['di'] = dirname($filename) . '/'
51  . (isset($this->config['config']['profile']['di'])
52  ? $this->config['config']['profile']['di']
53  : '../../config/di.xml'
54  );
55  }
56 
65  public function getValue($key, $default = null)
66  {
67  return isset($this->config['config']['profile'][$key]) ?
68  (
69  // Work around for how attributes are handled in the XML parser when injected via xinclude due to the
70  // files existing outside of the current working directory.
71  isset($this->config['config']['profile'][$key]['_value']) ?
72  $this->config['config']['profile'][$key]['_value'] : $this->config['config']['profile'][$key]
73  ) : $default;
74  }
75 }