Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TypePool.php
Go to the documentation of this file.
1 <?php
7 
9 
18 class TypePool
19 {
23  const TYPE_SENSITIVE = 'sensitive';
24 
28  const TYPE_ENVIRONMENT = 'environment';
29 
35  private $sensitive;
36 
42  private $environment;
43 
49  private $filteredPaths;
50 
61  private $excludeList;
62 
68  public function __construct(array $sensitive = [], array $environment = [], ExcludeList $excludeList = null)
69  {
70  $this->sensitive = $sensitive;
71  $this->environment = $environment;
72  $this->excludeList = $excludeList;
73  }
74 
88  public function isPresent($path, $type)
89  {
90  if (!isset($this->filteredPaths[$type])) {
91  $this->filteredPaths[$type] = $this->getPathsByType($type);
92  }
93 
94  $isPresent = in_array($path, $this->filteredPaths[$type]);
95 
96  if ($type == self::TYPE_SENSITIVE
97  && !$isPresent
98  && $this->excludeList instanceof ExcludeList
99  ) {
100  $isPresent = $this->excludeList->isPresent($path);
101  }
102 
103  return $isPresent;
104  }
105 
124  private function getPathsByType($type)
125  {
126  switch ($type) {
128  $paths = $this->sensitive;
129  break;
131  $paths = $this->environment;
132  break;
133  default:
134  return [];
135  }
136 
137  return array_keys(array_filter(
138  $paths,
139  function ($value) {
140  return filter_var($value, FILTER_VALIDATE_BOOLEAN);
141  }
142  ));
143  }
144 }
$type
Definition: item.phtml:13
$value
Definition: gender.phtml:16
__construct(array $sensitive=[], array $environment=[], ExcludeList $excludeList=null)
Definition: TypePool.php:68
$paths
Definition: _bootstrap.php:83