function ProjectCoreCompatibility::setReleaseMessage

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

Sets core compatibility messages for project releases.

Parameters

array &$project_data: The project data as returned by \Drupal\update\UpdateManagerInterface::getProjects() and then processed by update_process_project_info() and update_calculate_project_update_status(). If set, the following keys are used in this method:

  • recommended (string): A project version number.
  • latest_version (string): A project version number.
  • also (string[]): Project version numbers.
  • releases (array[]): An array where the keys are project version numbers and the values are arrays of project release information.
  • security updates (array[]): An array of project release information.

See also

\Drupal\update\UpdateManagerInterface::getProjects()

update_process_project_info()

update_calculate_project_update_status()

File

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

Class

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

Namespace

Drupal\update

Code

public function setReleaseMessage(array &$project_data) {
    if (empty($this->possibleCoreUpdateVersions)) {
        return;
    }
    // Get the various releases that will need to have core compatibility
    // messages added to them.
    $releases_to_set = [];
    $versions = [];
    if (!empty($project_data['recommended'])) {
        $versions[] = $project_data['recommended'];
    }
    if (!empty($project_data['latest_version'])) {
        $versions[] = $project_data['latest_version'];
    }
    if (!empty($project_data['also'])) {
        $versions = array_merge($versions, $project_data['also']);
    }
    foreach ($versions as $version) {
        if (isset($project_data['releases'][$version])) {
            $releases_to_set[] =& $project_data['releases'][$version];
        }
    }
    if (!empty($project_data['security updates'])) {
        foreach ($project_data['security updates'] as &$security_update) {
            $releases_to_set[] =& $security_update;
        }
    }
    foreach ($releases_to_set as &$release) {
        if (!empty($release['core_compatibility'])) {
            $release['core_compatible'] = $this->isCoreCompatible($release['core_compatibility']);
            $release['core_compatibility_message'] = $this->createMessageFromCoreCompatibility($release['core_compatibility']);
        }
    }
}

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