class ModuleInfo

Extends CacheArray to lazy load .info properties for modules.

Use system_get_module_info() rather than instantiating this class directly.

Hierarchy

Expanded class hierarchy of ModuleInfo

1 file declares its use of ModuleInfo
system.module in drupal/core/modules/system/system.module
Configuration system that lets administrators modify the workings of the site.

File

drupal/core/lib/Drupal/Core/Utility/ModuleInfo.php, line 17
Definition of Drupal\Core\Utility\ModuleInfo.

Namespace

Drupal\Core\Utility
View source
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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheArray::$bin protected property A bin to pass to cache()->set() and cache()->get().
CacheArray::$cid protected property A cid to pass to cache()->set() and cache()->get().
CacheArray::$keysToPersist protected property An array of keys to add to the cache at the end of the request.
CacheArray::$storage protected property Storage for the data itself.
CacheArray::$tags protected property A tags array to pass to cache()->set().
CacheArray::offsetExists public function Implements ArrayAccess::offsetExists(). 1
CacheArray::offsetGet public function Implements ArrayAccess::offsetGet(). 1
CacheArray::offsetSet public function Implements ArrayAccess::offsetSet().
CacheArray::offsetUnset public function Implements ArrayAccess::offsetUnset().
CacheArray::persist protected function Flags an offset value to be written to the persistent cache.
CacheArray::set protected function Writes a value to the persistent cache immediately. 1
CacheArray::__construct public function Constructs a CacheArray object. 3
CacheArray::__destruct public function Destructs the CacheArray object.
ModuleInfo::$info protected property The full module info array as returned by system_get_info().
ModuleInfo::resolveCacheMiss function Implements CacheArray::resolveCacheMiss(). Overrides CacheArray::resolveCacheMiss