Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConcealInProductionConfigList.php
Go to the documentation of this file.
1 <?php
7 
9 
19 {
38  private $configs = [];
39 
45  private $state;
46 
51  public function __construct(State $state, array $configs = [])
52  {
53  $this->state = $state;
54  $this->configs = $configs;
55  }
56 
62  public function isHidden($path)
63  {
64  $path = $this->normalizePath($path);
65 
66  return $this->state->getMode() === State::MODE_PRODUCTION
67  && !empty($this->configs[$path])
68  && $this->configs[$path] === static::HIDDEN;
69  }
70 
76  public function isDisabled($path)
77  {
78  $path = $this->normalizePath($path);
79  if ($this->state->getMode() === State::MODE_PRODUCTION) {
80  while (true) {
81  if (!empty($this->configs[$path])) {
82  return $this->configs[$path] === static::DISABLED;
83  }
84 
85  $position = strripos($path, '/');
86  if ($position === false) {
87  break;
88  }
89  $path = substr($path, 0, $position);
90  }
91  }
92 
93  return false;
94  }
95 
102  private function normalizePath($path)
103  {
104  return trim($path, '/');
105  }
106 }