Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
ModuleList Class Reference
Inheritance diagram for ModuleList:
ModuleListInterface

Public Member Functions

 __construct (DeploymentConfig $config, ModuleList\Loader $loader)
 
 getAll ()
 
 getOne ($name)
 
 getNames ()
 
 has ($name)
 
 isModuleInfoAvailable ()
 

Detailed Description

A list of modules in the Magento application

Encapsulates information about whether modules are enabled or not. Represents only enabled modules through its interface

Definition at line 17 of file ModuleList.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( DeploymentConfig  $config,
ModuleList\Loader  $loader 
)

Constructor

Parameters
DeploymentConfig$config
ModuleList\Loader$loader

Definition at line 55 of file ModuleList.php.

56  {
57  $this->config = $config;
58  $this->loader = $loader;
59  }

Member Function Documentation

◆ getAll()

getAll ( )

{Get list of all modulesReturns an array where key is module name and value is an array with module meta-information

Returns
array
}

Note that this triggers loading definitions of all existing modules in the system. Use this method only when you actually need modules' declared meta-information.

See also
getNames()

Implements ModuleListInterface.

Definition at line 69 of file ModuleList.php.

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  }
$value
Definition: gender.phtml:16

◆ getNames()

getNames ( )

{Enumerates the list of names of modules

Returns
string[]
}

Implements ModuleListInterface.

Definition at line 99 of file ModuleList.php.

100  {
101  $this->loadConfigData();
102  if (!$this->configData) {
103  return [];
104  }
105  $result = array_keys(array_filter($this->configData));
106  return $result;
107  }

◆ getOne()

getOne (   $name)

{Get module declaration dataReturns an array with meta-information about one module by specified name

Parameters
string$name
Returns
array|null
}

See also
has()

Implements ModuleListInterface.

Definition at line 90 of file ModuleList.php.

91  {
92  $enabled = $this->getAll();
93  return $enabled[$name] ?? null;
94  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ has()

has (   $name)

{Checks whether the specified module is present in the list

Parameters
string$name
Returns
bool
}

Implements ModuleListInterface.

Definition at line 112 of file ModuleList.php.

113  {
114  $this->loadConfigData();
115  if (!$this->configData) {
116  return false;
117  }
118  return !empty($this->configData[$name]);
119  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ isModuleInfoAvailable()

isModuleInfoAvailable ( )

Checks if module list information is available.

Returns
bool

Definition at line 126 of file ModuleList.php.

127  {
128  $this->loadConfigData();
129  if ($this->configData) {
130  return true;
131  }
132  return false;
133  }

The documentation for this class was generated from the following file: