Commit 2dc655fe authored by catch's avatar catch

Issue #2025779 by Berdir, ianthomas_uk: Remove ModuleInfo as it is no longer necessary.

parent aba98c73
......@@ -2446,12 +2446,12 @@ function drupal_classloader_register($name, $path) {
*
* Example:
* @code
* function system_get_module_info($property) {
* static $info;
* if (!isset($info)) {
* $info = new ModuleInfo('system_info', 'cache');
* function drupal_session_started($set = NULL) {
* static $session_started = FALSE;
* if (isset($set)) {
* $session_started = $set;
* }
* return $info[$property];
* return $session_started && session_id();
* }
* @endcode
*
......
<?php
/**
* @file
* Definition of Drupal\Core\Utility\ModuleInfo.
*/
namespace Drupal\Core\Utility;
use Drupal\Core\Utility\CacheArray;
/**
* Extends CacheArray to lazy load .info.yml properties for modules.
*
* Use system_get_module_info() rather than instantiating this class directly.
*/
class ModuleInfo extends CacheArray {
/**
* The full module info array as returned by system_get_info().
*/
protected $info;
/**
* Implements CacheArray::resolveCacheMiss().
*/
function resolveCacheMiss($offset) {
$data = array();
if (!isset($this->info)) {
$this->info = system_get_info('module');
}
foreach ($this->info as $module => $info) {
if (isset($info[$offset])) {
$data[$module] = $info[$offset];
}
}
$this->storage[$offset] = $data;
$this->persist($offset);
return $data;
}
}
......@@ -2551,27 +2551,6 @@ function system_get_info($type, $name = NULL) {
return $info;
}
/**
* Return .info.yml data for modules.
*
* @param string $property
* The .info.yml property to retrieve.
*
* @return array
* An array keyed by module name, with the .info.yml file property as values.
* Only modules with the property specified in their .info.yml file will be
* returned.
*
* @see \Drupal\Core\Utility\ModuleInfo
*/
function system_get_module_info($property) {
static $info;
if (!isset($info)) {
$info = new ModuleInfo('system_info', 'cache');
}
return $info[$property];
}
/**
* Helper function to scan and collect module .info.yml data.
*
......
......@@ -66,12 +66,18 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$modules = system_get_info('module');
$names = array();
foreach ($modules as $name => $module) {
$names[$name] = $module['name'];
}
$form['data_module'] = array(
'#title' => t('Module name'),
'#type' => 'select',
'#description' => t('The module which sets this user data.'),
'#default_value' => $this->options['data_module'],
'#options' => system_get_module_info('name'),
'#options' => $names,
);
$form['data_name'] = array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment