function ProjectCoreCompatibility::createMessageFromCoreCompatibility

Same name in other branches
  1. 9 core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::createMessageFromCoreCompatibility()
  2. 8.9.x core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::createMessageFromCoreCompatibility()
  3. 11.x core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::createMessageFromCoreCompatibility()

Creates core a compatibility message from a semantic version constraint.

Parameters

string $core_compatibility_constraint: A semantic version constraint.

Return value

string The core compatibility message.

1 call to ProjectCoreCompatibility::createMessageFromCoreCompatibility()
ProjectCoreCompatibility::setReleaseMessage in core/modules/update/src/ProjectCoreCompatibility.php
Sets core compatibility messages for project releases.

File

core/modules/update/src/ProjectCoreCompatibility.php, line 189

Class

ProjectCoreCompatibility
Utility class to set core compatibility messages for project releases.

Namespace

Drupal\update

Code

protected function createMessageFromCoreCompatibility($core_compatibility_constraint) {
    if (!isset($this->compatibilityMessages[$core_compatibility_constraint])) {
        $core_compatibility_ranges = $this->getCompatibilityRanges($core_compatibility_constraint);
        $range_messages = [];
        foreach ($core_compatibility_ranges as $core_compatibility_range) {
            if (count($core_compatibility_range) === 2) {
                $range_messages[] = $this->t('@low_version_number to @high_version_number', [
                    '@low_version_number' => $core_compatibility_range[0],
                    '@high_version_number' => $core_compatibility_range[1],
                ]);
            }
            else {
                $range_messages[] = $core_compatibility_range[0];
            }
        }
        $this->compatibilityMessages[$core_compatibility_constraint] = $this->t('Requires Drupal core:') . ' ' . implode(', ', $range_messages);
    }
    return $this->compatibilityMessages[$core_compatibility_constraint];
}

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