function ProjectRelease::createFromArray

Same name in other branches
  1. 9 core/modules/update/src/ProjectRelease.php \Drupal\update\ProjectRelease::createFromArray()
  2. 11.x core/modules/update/src/ProjectRelease.php \Drupal\update\ProjectRelease::createFromArray()

Creates a ProjectRelease instance from an array.

Parameters

array $release_data: The project release data as returned by update_get_available().

Return value

\Drupal\update\ProjectRelease The ProjectRelease instance.

Throws

\UnexpectedValueException Thrown if project release data is not valid.

See also

\update_get_available()

8 calls to ProjectRelease::createFromArray()
ProjectReleaseTest::testCreateFromArray in core/modules/update/tests/src/Unit/ProjectReleaseTest.php
Tests creating with valid data.
ProjectReleaseTest::testCreateFromArrayInvalidField in core/modules/update/tests/src/Unit/ProjectReleaseTest.php
Tests exceptions for invalid field types.
ProjectReleaseTest::testCreateFromArrayMissingField in core/modules/update/tests/src/Unit/ProjectReleaseTest.php
Tests exceptions with missing fields.
ProjectReleaseTest::testOptionalFields in core/modules/update/tests/src/Unit/ProjectReleaseTest.php
Tests that optional fields can be omitted.
ProjectSecurityData::getAdditionalSecurityCoveredMinors in core/modules/update/src/ProjectSecurityData.php
Gets the number of additional minor releases with security coverage.

... See full list

File

core/modules/update/src/ProjectRelease.php, line 118

Class

ProjectRelease
Provides a project release value object.

Namespace

Drupal\update

Code

public static function createFromArray(array $release_data) : ProjectRelease {
    static::validateReleaseData($release_data);
    return new ProjectRelease($release_data['status'] === 'published', $release_data['version'], $release_data['release_link'], $release_data['terms']['Release type'] ?? NULL, $release_data['core_compatible'] ?? NULL, $release_data['core_compatibility_message'] ?? NULL, $release_data['download_link'] ?? NULL, $release_data['date'] ?? NULL);
}

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