You are here

protected static function AutomaticUpdatesPsa::parseConstraints in Automatic Updates 7

Compare versions and add a message, if appropriate.

Parameters

array $messages: The messages array.

object $json: The JSON object.

string $current_version: The current extension version.

Throws

\UnexpectedValueException

2 calls to AutomaticUpdatesPsa::parseConstraints()
AutomaticUpdatesPsa::contribParser in ./AutomaticUpdatesPsa.php
Parse contrib project JSON version strings.
AutomaticUpdatesPsa::getPublicServiceMessages in ./AutomaticUpdatesPsa.php

File

./AutomaticUpdatesPsa.php, line 107
Contains AutomaticUpdatesPsa class.

Class

AutomaticUpdatesPsa
Class AutomaticUpdatesPsa.

Code

protected static function parseConstraints(array &$messages, $json, $current_version) {
  $version_string = implode('||', $json->insecure);
  if (empty($version_string)) {
    return;
  }
  $project_root = drupal_get_path('module', 'automatic_updates');
  require_once $project_root . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
  $parser = new VersionParser();
  $psa_constraint = $parser
    ->parseConstraints($version_string);
  $contrib_constraint = $parser
    ->parseConstraints($current_version);
  if ($psa_constraint
    ->matches($contrib_constraint)) {
    $messages[] = static::message($json->title, $json->link);
  }
}