class InfoParserDynamic implements InfoParserInterface (View source)

Parses dynamic .info.yml files that might change during the page request.

Constants

FIRST_CORE_VERSION_REQUIREMENT_SUPPORTED_VERSION

The earliest Drupal version that supports the 'core_version_requirement'.

Properties

protected string $root

The root directory of the Drupal installation.

Methods

__construct(string $app_root = NULL)

InfoParserDynamic constructor.

array
parse(string $filename)

Parses Drupal module, theme and profile .info.yml files.

array
getRequiredKeys()

Returns an array of keys required to exist in .info.yml file.

static bool
isConstraintSatisfiedByPreviousVersion(string $constraint, string $version)

Determines if a constraint is satisfied by earlier versions of Drupal 8.

static array
getAllPreviousCoreVersions(string $version)

Gets all the versions of Drupal 8 before a specific version.

Details

__construct(string $app_root = NULL)

InfoParserDynamic constructor.

Parameters

string $app_root

The root directory of the Drupal installation.

array parse(string $filename)

Parses Drupal module, theme and profile .info.yml files.

Info files are NOT for placing arbitrary theme and module-specific settings. Use Config::get() and Config::set()->save() for that. Info files are formatted as YAML. If the 'version' key is set to 'VERSION' in any info file, then the value will be substituted with the current version of Drupal core.

Information stored in all .info.yml files:

  • name: The real name of the module for display purposes. (Required)
  • description: A brief description of the module.
  • type: whether it is for a module or theme. (Required)
  • lifecycle: [experimental|stable|deprecated|obsolete]. A description of the current phase in the lifecycle of the module, theme or profile.

Information stored in a module .info.yml file:

  • dependencies: An array of dependency strings. Each is in the form 'project:module (versions)'; with the following meanings:
    • project: (optional) Project shortname, recommended to ensure uniqueness, if the module is part of a project hosted on drupal.org. If omitted, also omit the : that follows. The project name is currently ignored by Drupal core but is used for automated testing.
    • module: (required) Module shortname within the project.
    • (versions): Version information, consisting of one or more comma-separated operator/value pairs or simply version numbers, which can contain "x" as a wildcard. Examples: (>=8.22, <8.28), (8.x-3.x).
  • package: The name of the package of modules this module belongs to.

See forum.info.yml for an example of a module .info.yml file.

Information stored in a theme .info.yml file:

  • screenshot: Path to screenshot relative to the theme's .info.yml file.
  • engine: Theme engine; typically twig.
  • base theme: Name of a base theme, if applicable.
  • regions: Listed regions.
  • features: Features available.
  • stylesheets: Theme stylesheets.
  • scripts: Theme scripts.

See bartik.info.yml for an example of a theme .info.yml file.

For information stored in a profile .info.yml file see install_profile_info().

Parameters

string $filename

The file we are parsing. Accepts file with relative or absolute path.

Return Value

array

The info array.

Exceptions

InfoParserException

protected array getRequiredKeys()

Returns an array of keys required to exist in .info.yml file.

Return Value

array

An array of required keys.

static protected bool isConstraintSatisfiedByPreviousVersion(string $constraint, string $version)

Determines if a constraint is satisfied by earlier versions of Drupal 8.

Parameters

string $constraint

A core semantic version constraint.

string $version

A core version.

Return Value

bool

TRUE if the constraint is satisfied by a core version prior to the provided version.

static protected array getAllPreviousCoreVersions(string $version)

Gets all the versions of Drupal 8 before a specific version.

Parameters

string $version

The version to get versions before.

Return Value

array

All of the applicable Drupal 8 releases.