function LocaleProjectStorage::getMultiple

Same name in other branches
  1. 8.9.x core/modules/locale/src/LocaleProjectStorage.php \Drupal\locale\LocaleProjectStorage::getMultiple()
  2. 10 core/modules/locale/src/LocaleProjectStorage.php \Drupal\locale\LocaleProjectStorage::getMultiple()
  3. 11.x core/modules/locale/src/LocaleProjectStorage.php \Drupal\locale\LocaleProjectStorage::getMultiple()

Overrides LocaleProjectStorageInterface::getMultiple

1 call to LocaleProjectStorage::getMultiple()
LocaleProjectStorage::get in core/modules/locale/src/LocaleProjectStorage.php
Returns the stored value for a given key.

File

core/modules/locale/src/LocaleProjectStorage.php, line 54

Class

LocaleProjectStorage
Provides the locale project storage system using a key value store.

Namespace

Drupal\locale

Code

public function getMultiple(array $keys) {
    $values = [];
    $load = [];
    foreach ($keys as $key) {
        // Check if we have a value in the cache.
        if (isset($this->cache[$key])) {
            $values[$key] = $this->cache[$key];
        }
        elseif (!array_key_exists($key, $this->cache)) {
            $load[] = $key;
        }
    }
    if ($load) {
        $loaded_values = $this->keyValueStore
            ->getMultiple($load);
        foreach ($load as $key) {
            // If we find a value, even one that is NULL, add it to the cache and
            // return it.
            if (isset($loaded_values[$key])) {
                $values[$key] = $loaded_values[$key];
                $this->cache[$key] = $loaded_values[$key];
            }
            else {
                $this->cache[$key] = NULL;
            }
        }
    }
    return $values;
}

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