You are here

protected function AutomaticUpdatesPsa::parseConstraints in Automatic Updates 8

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 src/Services/AutomaticUpdatesPsa.php
Parse contrib project JSON version strings.
AutomaticUpdatesPsa::getPublicServiceMessages in src/Services/AutomaticUpdatesPsa.php
Get public service messages.

File

src/Services/AutomaticUpdatesPsa.php, line 224

Class

AutomaticUpdatesPsa
Class AutomaticUpdatesPsa.

Namespace

Drupal\automatic_updates\Services

Code

protected function parseConstraints(array &$messages, $json, $current_version) {
  $version_string = implode('||', $json->insecure);
  if (empty($version_string)) {
    return;
  }
  $parser = new VersionParser();
  $psa_constraint = $parser
    ->parseConstraints($version_string);
  $contrib_constraint = $parser
    ->parseConstraints($current_version);
  if ($psa_constraint
    ->matches($contrib_constraint)) {
    $messages[] = $this
      ->message($json->title, $json->link);
  }
}