b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / vendor / magento / framework / App /
Filename/home/a/home/dev2.destoffenstraat.com/vendor/magento/framework/App/DeploymentConfig.php
Size4.6 kb
Permissionrw-r--r--
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified07-Jan-2021 21:08
Last accessed23-Aug-2025 00:37
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\App;

use Magento\Framework\Config\ConfigOptionsListConstants;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Exception\RuntimeException;
use Magento\Framework\Phrase;

/**
* Application deployment configuration
*
* @api
* @since 100.0.2
*/
class DeploymentConfig
{
/**
* Configuration reader
*
* @var DeploymentConfig\Reader
*/
private $reader;

/**
* Configuration data
*
* @var array
*/
private $data;

/**
* Flattened data
*
* @var array
*/
private $flatData;

/**
* Injected configuration data
*
* @var array
*/
private $overrideData;

/**
* Constructor
*
* Data can be optionally injected in the constructor. This object's public interface is intentionally immutable
*
* @param DeploymentConfig\Reader $reader
* @param array $overrideData
*/
public function __construct(DeploymentConfig\Reader $reader, $overrideData = [])
{
$this->reader = $reader;
$this->overrideData = $overrideData;
}

/**
* Gets data from flattened data
*
* @param string $key
* @param mixed $defaultValue
* @return mixed|null
* @throws FileSystemException
* @throws RuntimeException
*/
public function get($key = null, $defaultValue = null)
{
$this->load();
if ($key === null) {
return $this->flatData;
}

if (array_key_exists($key, $this->flatData) && $this->flatData[$key] === null) {
return '';
}

return $this->flatData[$key] ?? $defaultValue;
}

/**
* Checks if data available
*
* @return bool
* @throws FileSystemException
* @throws RuntimeException
*/
public function isAvailable()
{
$this->load();
return isset($this->flatData[ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE]);
}

/**
* Gets a value specified key from config data
*
* @param string $key
* @return null|mixed
* @throws FileSystemException
* @throws RuntimeException
*/
public function getConfigData($key = null)
{
$this->load();

if ($key !== null && !isset($this->data[$key])) {
return null;
}

return $this->data[$key] ?? $this->data;
}

/**
* Resets config data
*
* @return void
*/
public function resetData()
{
$this->data = null;
}

/**
* Check if data from deploy files is available
*
* @return bool
* @throws FileSystemException
* @throws RuntimeException
* @since 100.1.3
*/
public function isDbAvailable()
{
$this->load();
return isset($this->data['db']);
}

/**
* Loads the configuration data
*
* @return void
* @throws FileSystemException
* @throws RuntimeException
*/
private function load()
{
if (empty($this->data)) {
$this->data = $this->reader->load();
if ($this->overrideData) {
$this->data = array_replace($this->data, $this->overrideData);
}
// flatten data for config retrieval using get()
$this->flatData = $this->flattenParams($this->data);
}
}

/**
* Array keys conversion
*
* Convert associative array of arbitrary depth to a flat associative array with concatenated key path as keys
* each level of array is accessible by path key
*
* @param array $params
* @param string $path
* @param array $flattenResult
* @return array
* @throws RuntimeException
*/
private function flattenParams(array $params, $path = null, array &$flattenResult = null) : array
{
if (null === $flattenResult) {
$flattenResult = [];
}

foreach ($params as $key => $param) {
if ($path) {
$newPath = $path . '/' . $key;
} else {
$newPath = $key;
}
if (isset($flattenResult[$newPath])) {
//phpcs:ignore Magento2.Exceptions.DirectThrow
throw new RuntimeException(new Phrase("Key collision '%1' is already defined.", [$newPath]));
}
$flattenResult[$newPath] = $param;
if (is_array($param)) {
$this->flattenParams($param, $newPath, $flattenResult);
}
}

return $flattenResult;
}
}