![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-config/Model/Placeholder/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Config\Model\Placeholder; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\DeploymentConfig; /** * Class is used to work with placeholders for environment variables names based on config paths * @api * @since 100.1.2 */ class Environment implements PlaceholderInterface { /** * @const string Prefix for placeholder */ const PREFIX = 'CONFIG__'; /** * @var DeploymentConfig */ private $deploymentConfig; /** * @param DeploymentConfig $deploymentConfig */ public function __construct(DeploymentConfig $deploymentConfig) { $this->deploymentConfig = $deploymentConfig; } /** * Generates placeholder like CONFIG__DEFAULT__TEST__TEST_VALUE * * @inheritdoc * @since 100.1.2 */ public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null) { $parts = $scopeType ? [$scopeType] : []; if ($scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT && $scopeCode) { $parts[] = $scopeCode; } $parts[] = $path; $template = implode('__', $parts); $template = str_replace('/', '__', $template); $template = static::PREFIX . $template; $template = strtoupper($template); return $template; } /** * @inheritdoc * @since 100.1.2 */ public function restore($template) { $template = preg_replace('/^' . static::PREFIX . '/', '', $template); $template = str_replace('__', '/', $template); $template = strtolower($template); return $template; } /** * @inheritdoc * @since 100.1.2 */ public function isApplicable($placeholder) { return 1 === preg_match('/^' . static::PREFIX . '([a-zA-Z]+)([a-zA-Z0-9_])*$/', $placeholder); } }