Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
FixtureConfig Class Reference

Public Member Functions

 __construct (Parser $parser)
 
 loadConfig ($filename)
 
 getValue ($key, $default=null)
 

Detailed Description

Config data for fixtures

Definition at line 14 of file FixtureConfig.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Parser  $parser)
Parameters
Parser$parser

Definition at line 29 of file FixtureConfig.php.

30  {
31  $this->parser = $parser;
32  }

Member Function Documentation

◆ getValue()

getValue (   $key,
  $default = null 
)

Get profile configuration value

Parameters
string$key
null | mixed$default
Returns
mixed

Definition at line 65 of file FixtureConfig.php.

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  }

◆ loadConfig()

loadConfig (   $filename)

Load config from file

Parameters
string$filename
Exceptions

Definition at line 42 of file FixtureConfig.php.

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  }

The documentation for this class was generated from the following file: