function InfoParserDynamic::isConstraintSatisfiedByPreviousVersion

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Extension/InfoParserDynamic.php \Drupal\Core\Extension\InfoParserDynamic::isConstraintSatisfiedByPreviousVersion()

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.

1 call to InfoParserDynamic::isConstraintSatisfiedByPreviousVersion()
InfoParserDynamic::parse in core/lib/Drupal/Core/Extension/InfoParserDynamic.php
Parses Drupal module, theme and profile .info.yml files.

File

core/lib/Drupal/Core/Extension/InfoParserDynamic.php, line 155

Class

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

Namespace

Drupal\Core\Extension

Code

protected static function isConstraintSatisfiedByPreviousVersion($constraint, $version) {
    static $evaluated_constraints = [];
    // Any particular constraint and version combination only needs to be
    // evaluated once.
    if (!isset($evaluated_constraints[$constraint][$version])) {
        $evaluated_constraints[$constraint][$version] = FALSE;
        foreach (static::getAllPreviousCoreVersions($version) as $previous_version) {
            if (Semver::satisfies($previous_version, $constraint)) {
                $evaluated_constraints[$constraint][$version] = TRUE;
                // The constraint only has to satisfy one previous version so break
                // when the first one is found.
                break;
            }
        }
    }
    return $evaluated_constraints[$constraint][$version];
}

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