class UpdateServerProjectInfo

Same name and namespace in other branches
  1. 11.x core/modules/update/src/UpdateServerProjectInfo.php \Drupal\update\UpdateServerProjectInfo

Update server project information.

The information from the server about available updates for an individual project.

Hierarchy

Expanded class hierarchy of UpdateServerProjectInfo

See also

\Drupal\update\UpdateCalculator

1 file declares its use of UpdateServerProjectInfo
update.compare.inc in core/modules/update/update.compare.inc

File

core/modules/update/src/UpdateServerProjectInfo.php, line 15

Namespace

Drupal\update
View source
class UpdateServerProjectInfo extends \ArrayObject {
  
  /**
   * A value object to track available updates.
   *
   * @param string|null $status
   *   The status of the available update.
   * @param array $supportedBranches
   *   The branches the update supports.
   * @param array $releases
   *   The releases available for the project.
   * @param string $title
   *   The title of the project.
   * @param string $link
   *   A link to the project.
   * @param int|null $fetchStatus
   *   One of:
   *    - UpdateFetcherInterface::NOT_CHECKED
   *    - UpdateFetcherInterface::UNKNOWN
   *    - UpdateFetcherInterface::NOT_FETCHED
   *    - UpdateFetcherInterface::FETCH_PENDING.
   * @param int|null $lastFetch
   *   When the last project was fetched.
   * @param string|null $shortName
   *   The shortname of the project.
   * @param string|null $terms
   *   Release type, one of:
   *    - Security update
   *    - Unsupported
   *    - Insecure.
   */
  public function __construct(public ?string $status = NULL, public array $supportedBranches = [], public array $releases = [], public string $title = '', public string $link = '', public ?int $fetchStatus = NULL, public ?int $lastFetch = NULL, public ?string $shortName = NULL, public ?string $terms = NULL) {
  }
  
  /**
   * Creates a UpdateServerProjectInfo object.
   *
   * @param array $data
   *   The project data from the Update XML.
   *
   * @return static
   */
  public static function createFromArray(array $data) : static {
    $data['supported_branches'] ??= [];
    return new UpdateServerProjectInfo($data['project_status'] ?? NULL, $data['supported_branches'] ? explode(',', $data['supported_branches']) : [], $data['releases'] ?? [], $data['title'] ?? '', $data['link'] ?? '', $data['fetch_status'] ?? NULL, $data['last_fetch'] ?? NULL, $data['short_name'] ?? NULL, $data['terms'] ?? NULL);
  }

}

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