Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ModuleList.php
Go to the documentation of this file.
1 <?php
7 
10 
18 {
24  private $config;
25 
31  private $loader;
32 
40  private $configData;
41 
47  private $enabled;
48 
55  public function __construct(DeploymentConfig $config, ModuleList\Loader $loader)
56  {
57  $this->config = $config;
58  $this->loader = $loader;
59  }
60 
69  public function getAll()
70  {
71  if (null === $this->enabled) {
72  $all = $this->loader->load();
73  if (empty($all)) {
74  return []; // don't record erroneous value into memory
75  }
76  $this->enabled = [];
77  foreach ($all as $key => $value) {
78  if ($this->has($key)) {
79  $this->enabled[$key] = $value;
80  }
81  }
82  }
83  return $this->enabled;
84  }
85 
90  public function getOne($name)
91  {
92  $enabled = $this->getAll();
93  return $enabled[$name] ?? null;
94  }
95 
99  public function getNames()
100  {
101  $this->loadConfigData();
102  if (!$this->configData) {
103  return [];
104  }
105  $result = array_keys(array_filter($this->configData));
106  return $result;
107  }
108 
112  public function has($name)
113  {
114  $this->loadConfigData();
115  if (!$this->configData) {
116  return false;
117  }
118  return !empty($this->configData[$name]);
119  }
120 
126  public function isModuleInfoAvailable()
127  {
128  $this->loadConfigData();
129  if ($this->configData) {
130  return true;
131  }
132  return false;
133  }
134 
140  private function loadConfigData()
141  {
142  $this->config->resetData();
143  if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
144  $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
145  }
146  }
147 }
$config
Definition: fraud_order.php:17
__construct(DeploymentConfig $config, ModuleList\Loader $loader)
Definition: ModuleList.php:55
$loader
Definition: autoload.php:8
$value
Definition: gender.phtml:16
if(!isset($_GET['name'])) $name
Definition: log.php:14