You are here

public function Files::get in Advanced CSS/JS Aggregation 8.2

Returns the stored value for a given key.

Parameters

string $key: The key of the data to retrieve.

mixed $default: The default value to use if the key is not found.

Return value

mixed The stored value, or NULL if no value exists.

Overrides State::get

1 call to Files::get()
Files::getMultiple in src/State/Files.php
Returns the stored key/value pairs for a given set of keys.

File

src/State/Files.php, line 221
Given a filename calculate various hashes and gather meta data.

Class

Files
Provides AdvAgg with a file status state system using a key value store.

Namespace

Drupal\advagg\State

Code

public function get($key, $default = NULL) {

  // https://api.drupal.org/api/drupal/core!lib!Drupal!Core!State!State.php/function/State::get/8.3.x
  // Passthrough for Drupal 8.3+.
  if (version_compare(\Drupal::VERSION, '8.3.0') >= 0) {
    return parent::get($key, $default);
  }

  // https://api.drupal.org/api/drupal/core!lib!Drupal!Core!State!State.php/function/State::get/8.2.x
  // Use State::getMultiple vs Files::getMultiple for older Drupal 8 versions.
  $values = parent::getMultiple([
    $key,
  ]);
  return isset($values[$key]) ? $values[$key] : $default;
}