Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EnvironmentConfigSource.php
Go to the documentation of this file.
1 <?php
7 
13 
21 {
27  private $arrayManager;
28 
34  private $placeholder;
35 
40  public function __construct(
41  ArrayManager $arrayManager,
42  PlaceholderFactory $placeholderFactory
43  ) {
44  $this->arrayManager = $arrayManager;
45  $this->placeholder = $placeholderFactory->create(PlaceholderFactory::TYPE_ENVIRONMENT);
46  }
47 
52  public function get($path = '')
53  {
54  $data = new DataObject($this->loadConfig());
55  return $data->getData($path) ?: [];
56  }
57 
63  private function loadConfig()
64  {
65  $config = [];
66 
67  $environmentVariables = $_ENV;
68 
69  foreach ($environmentVariables as $template => $value) {
70  if (!$this->placeholder->isApplicable($template)) {
71  continue;
72  }
73 
74  $config = $this->arrayManager->set(
75  $this->placeholder->restore($template),
76  $config,
77  $value
78  );
79  }
80 
81  return $config;
82  }
83 }
$config
Definition: fraud_order.php:17
__construct(ArrayManager $arrayManager, PlaceholderFactory $placeholderFactory)
$value
Definition: gender.phtml:16
$template
Definition: export.php:12