function ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo

Same name in other branches
  1. 8.9.x core/modules/update/src/ProjectSecurityRequirement.php \Drupal\update\ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo()
  2. 10 core/modules/update/src/ProjectSecurityRequirement.php \Drupal\update\ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo()
  3. 11.x core/modules/update/src/ProjectSecurityRequirement.php \Drupal\update\ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo()

Creates a ProjectSecurityRequirement object from project data.

Parameters

array $project_data: Project data from Drupal\update\UpdateManagerInterface::getProjects(). The 'security_coverage_info' key should be set by calling \Drupal\update\ProjectSecurityData::getCoverageInfo() before calling this method. The following keys are used in this method:

  • existing_version (string): The version of the project that is installed on the site.
  • project_type (string): The type of project.
  • name (string): The project machine name.
  • title (string): The project title.

array $security_coverage_info: The security coverage information as returned by \Drupal\update\ProjectSecurityData::getCoverageInfo().

Return value

static

See also

\Drupal\update\UpdateManagerInterface::getProjects()

\Drupal\update\ProjectSecurityData::getCoverageInfo()

update_process_project_info()

File

core/modules/update/src/ProjectSecurityRequirement.php, line 95

Class

ProjectSecurityRequirement
Class for generating a project's security requirement.

Namespace

Drupal\update

Code

public static function createFromProjectDataAndSecurityCoverageInfo(array $project_data, array $security_coverage_info) {
    if ($project_data['project_type'] !== 'core' || $project_data['name'] !== 'drupal' || empty($security_coverage_info)) {
        return new static();
    }
    if (isset($project_data['existing_version'])) {
        [
            $major,
            $minor,
        ] = explode('.', $project_data['existing_version']);
        $existing_version = "{$major}.{$minor}";
        $next_version = "{$major}." . ((int) $minor + 1);
        return new static($project_data['title'], $security_coverage_info, $existing_version, $next_version);
    }
    return new static($project_data['title'], $security_coverage_info);
}

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