UpdateFetcherInterface.php 2.26 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

namespace Drupal\update;

/**
 * Fetches project information from remote locations.
 */
interface UpdateFetcherInterface {

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
  /**
   * Project's status cannot be checked.
   */
  const NOT_CHECKED = -1;

  /**
   * No available update data was found for project.
   */
  const UNKNOWN = -2;

  /**
   * There was a failure fetching available update data for this project.
   */
  const NOT_FETCHED = -3;

  /**
   * We need to (re)fetch available update data for this project.
   */
  const FETCH_PENDING = -4;

30 31 32 33
  /**
   * Returns the base of the URL to fetch available update data for a project.
   *
   * @param array $project
34 35
   *   The array of project information from
   *   \Drupal\Update\UpdateManager::getProjects().
36 37 38 39 40 41 42 43 44 45 46 47
   *
   * @return string
   *   The base of the URL used for fetching available update data. This does
   *   not include the path elements to specify a particular project, version,
   *   site_key, etc.
   */
  public function getFetchBaseUrl($project);

  /**
   * Retrieves the project information.
   *
   * @param array $project
48 49
   *   The array of project information from
   *   \Drupal\Update\UpdateManager::getProjects().
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
   * @param string $site_key
   *   (optional) The anonymous site key hash. Defaults to an empty string.
   *
   * @return string
   *   The project information fetched as string. Empty string upon failure.
   */
  public function fetchProjectData(array $project, $site_key = '');

  /**
   * Generates the URL to fetch information about project updates.
   *
   * This figures out the right URL to use, based on the project's .info.yml
   * file and the global defaults. Appends optional query arguments when the
   * site is configured to report usage stats.
   *
   * @param array $project
66 67
   *   The array of project information from
   *   \Drupal\Update\UpdateManager::getProjects().
68 69 70 71 72 73 74 75 76 77 78
   * @param string $site_key
   *   (optional) The anonymous site key hash. Defaults to an empty string.
   *
   * @return string
   *   The URL for fetching information about updates to the specified project.
   *
   * @see \Drupal\update\UpdateProcessor::fetchData()
   * @see \Drupal\update\UpdateProcessor::processFetchTask()
   * @see \Drupal\update\UpdateManager::getProjects()
   */
  public function buildFetchUrl(array $project, $site_key = '');
79

80
}