You are here

protected function ProjectCoreCompatibility::createMessageFromCoreCompatibility in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::createMessageFromCoreCompatibility()
  2. 9 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.

File

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

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];
}