function ExtensionVersion::createFromSupportBranch

Same name in other branches
  1. 10 core/lib/Drupal/Core/Extension/ExtensionVersion.php \Drupal\Core\Extension\ExtensionVersion::createFromSupportBranch()
  2. 11.x core/lib/Drupal/Core/Extension/ExtensionVersion.php \Drupal\Core\Extension\ExtensionVersion::createFromSupportBranch()

Constructs an ExtensionVersion version object from a support branch.

This can be used to determine the major version of the branch. ::getVersionExtra() will always return NULL for branches.

Parameters

string $branch: The support branch.

Return value

\Drupal\Core\Extension\ExtensionVersion The ExtensionVersion instance.

3 calls to ExtensionVersion::createFromSupportBranch()
ExtensionVersionTest::testCreateFromSupportBranch in core/tests/Drupal/Tests/Core/Extension/ExtensionVersionTest.php
@covers ::createFromSupportBranch
ExtensionVersionTest::testInvalidBranch in core/tests/Drupal/Tests/Core/Extension/ExtensionVersionTest.php
@covers ::createFromSupportBranch
ExtensionVersionTest::testInvalidBranchCorePrefix in core/tests/Drupal/Tests/Core/Extension/ExtensionVersionTest.php
@covers ::createFromSupportBranch

File

core/lib/Drupal/Core/Extension/ExtensionVersion.php, line 121

Class

ExtensionVersion
Provides an extension version value object.

Namespace

Drupal\Core\Extension

Code

public static function createFromSupportBranch(string $branch) : ExtensionVersion {
    if (substr($branch, -1) !== '.') {
        throw new \UnexpectedValueException("Invalid support branch: {$branch}");
    }
    return static::createFromVersionString($branch . '0');
}

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