class InfoParser

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Extension/InfoParser.php \Drupal\Core\Extension\InfoParser
  2. 9 core/lib/Drupal/Core/Extension/InfoParser.php \Drupal\Core\Extension\InfoParser
  3. 8.9.x core/lib/Drupal/Core/Extension/InfoParser.php \Drupal\Core\Extension\InfoParser

Parses extension .info.yml files.

Hierarchy

Expanded class hierarchy of InfoParser

3 files declare their use of InfoParser
GenerateTheme.php in core/lib/Drupal/Core/Command/GenerateTheme.php
InfoParserUnitTest.php in core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php
ThemeExtensionListTest.php in core/tests/Drupal/Tests/Core/Extension/ThemeExtensionListTest.php
1 string reference to 'InfoParser'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses InfoParser
info_parser in core/core.services.yml
Drupal\Core\Extension\InfoParser

File

core/lib/Drupal/Core/Extension/InfoParser.php, line 12

Namespace

Drupal\Core\Extension
View source
class InfoParser extends InfoParserDynamic {
  
  /**
   * The file cache.
   *
   * @var \Drupal\Component\FileCache\FileCacheInterface
   */
  protected FileCacheInterface $fileCache;
  
  /**
   * InfoParser constructor.
   *
   * @param string|null $app_root
   *   The root directory of the Drupal installation.
   */
  public function __construct(?string $app_root = NULL) {
    parent::__construct($app_root);
    if (FileCacheFactory::getPrefix() !== NULL) {
      $this->fileCache = FileCacheFactory::get('info_parser');
    }
    else {
      // Just use a static file cache when there is no prefix. This code path is
      // triggered when info is parsed prior to \Drupal\Core\DrupalKernel::boot()
      // running. This occurs during the very early installer and in some test
      // scenarios.
      $this->fileCache = new FileCache('info_parser', 'info_parser');
    }
  }
  
  /**
   * {@inheritdoc}
   */
  public function parse($filename) {
    $data = $this->fileCache
      ->get($filename);
    if ($data === NULL) {
      $data = parent::parse($filename);
      $this->fileCache
        ->set($filename, $data);
    }
    return $data;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.