ModuleList.php in X Autoload 7.5
File
tests/src/VirtualDrupal/ModuleList.php
View source
<?php
namespace Drupal\xautoload\Tests\VirtualDrupal;
class ModuleList {
private $drupalGetFilename;
private $systemList;
private $list = array();
private $moduleListSorted;
private $drupalStatic;
function __construct(DrupalGetFilename $drupalGetFilename, SystemList $systemList, DrupalStatic $drupalStatic) {
$this->drupalGetFilename = $drupalGetFilename;
$this->systemList = $systemList;
$this->drupalStatic = $drupalStatic;
}
function setModuleList($fixed_list, $sort = FALSE) {
foreach ($fixed_list as $name => $module) {
$this->drupalGetFilename
->drupalSetFilename('module', $name, $module['filename']);
$this->list[$name] = $name;
}
if ($sort) {
return $this
->moduleListSorted();
}
return $this->list;
}
function moduleList($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE) {
if (empty($this->list) || $refresh) {
$this->list = array();
$sorted_list = NULL;
if ($refresh) {
$this->drupalStatic
->resetKey('system_list');
}
if ($bootstrap_refresh) {
$this->list = $this->systemList
->systemListBootstrap();
}
else {
$this->list = array_keys($this->systemList
->systemListModuleEnabled());
$this->list = !empty($this->list) ? array_combine($this->list, $this->list) : array();
}
}
if ($sort) {
return $this
->moduleListSorted();
}
if (count($this->list)) {
}
return $this->list;
}
private function moduleListSorted() {
if (!isset($this->moduleListSorted)) {
$this->moduleListSorted = $this->list;
ksort($this->moduleListSorted);
}
return $this->moduleListSorted;
}
}