ModuleInfo.php 867 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

/**
 * @file
 * Definition of Drupal\Core\Utility\ModuleInfo.
 */

namespace Drupal\Core\Utility;

use Drupal\Core\Utility\CacheArray;

/**
 * Extends CacheArray to lazy load .info 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;

  /**
25
   * Implements CacheArray::resolveCacheMiss().
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
   */
  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;
  }
}