Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SettingChecker.php
Go to the documentation of this file.
1 <?php
7 
14 
21 {
25  private $config;
26 
30  private $placeholder;
31 
35  private $scopeCodeResolver;
36 
42  public function __construct(
43  DeploymentConfig $config,
44  PlaceholderFactory $placeholderFactory,
45  ScopeCodeResolver $scopeCodeResolver
46  ) {
47  $this->config = $config;
48  $this->scopeCodeResolver = $scopeCodeResolver;
49  $this->placeholder = $placeholderFactory->create(PlaceholderFactory::TYPE_ENVIRONMENT);
50  }
51 
61  public function isReadOnly($path, $scope, $scopeCode = null)
62  {
63  $config = $this->getEnvValue(
64  $this->placeholder->generate($path, $scope, $scopeCode)
65  );
66 
67  if (null === $config) {
68  $config = $this->config->get($this->resolvePath($scope, $scopeCode) . "/" . $path);
69  }
70 
71  return $config !== null;
72  }
73 
86  public function getPlaceholderValue($path, $scope, $scopeCode = null)
87  {
88  return $this->getEnvValue($this->placeholder->generate($path, $scope, $scopeCode));
89  }
90 
98  public function getEnvValue($placeholder)
99  {
100  if ($this->placeholder->isApplicable($placeholder) && isset($_ENV[$placeholder])) {
101  return $_ENV[$placeholder];
102  }
103 
104  return null;
105  }
106 
114  private function resolvePath($scope, $scopeCode)
115  {
116  $scopePath = 'system/' . $scope;
117 
119  $scopePath .= '/' . $this->scopeCodeResolver->resolve($scope, $scopeCode);
120  }
121 
122  return $scopePath;
123  }
124 }
$config
Definition: fraud_order.php:17
__construct(DeploymentConfig $config, PlaceholderFactory $placeholderFactory, ScopeCodeResolver $scopeCodeResolver)