Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function readMultiple(array $names)
 {
     $data = $this->storage->readMultiple($names);
     foreach ($names as $name) {
         if (isset($this->replacementData[$this->collection][$name])) {
             $data[$name] = $this->replacementData[$this->collection][$name];
         }
     }
     return $data;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getDefinitions()
 {
     $definitions = array();
     foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
         foreach ($schema as $type => $definition) {
             $definitions[$type] = $definition;
         }
     }
     return $definitions;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function readMultiple(array $names)
 {
     $dataList = $this->storage->readMultiple($names);
     $result = array();
     foreach ($dataList as $name => $data) {
         foreach ($this->filters as $filter) {
             $data = $filter->filterRead($name, $data);
         }
         $result[$name] = $data;
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function readMultiple(array $names)
 {
     $data_to_return = array();
     $cache_keys_map = $this->getCacheKeys($names);
     $cache_keys = array_values($cache_keys_map);
     $cached_list = $this->cache->getMultiple($cache_keys);
     if (!empty($cache_keys)) {
         // $cache_keys_map contains the full $name => $cache_key map, while
         // $cache_keys contains just the $cache_key values that weren't found in
         // the cache.
         // @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple()
         $names_to_get = array_keys(array_intersect($cache_keys_map, $cache_keys));
         $list = $this->storage->readMultiple($names_to_get);
         // Cache configuration objects that were loaded from the storage, cache
         // missing configuration objects as an explicit FALSE.
         $items = array();
         foreach ($names_to_get as $name) {
             $data = isset($list[$name]) ? $list[$name] : FALSE;
             $data_to_return[$name] = $data;
             $items[$cache_keys_map[$name]] = array('data' => $data);
         }
         $this->cache->setMultiple($items);
     }
     // Add the configuration objects from the cache to the list.
     $cache_keys_inverse_map = array_flip($cache_keys_map);
     foreach ($cached_list as $cache_key => $cache) {
         $name = $cache_keys_inverse_map[$cache_key];
         $data_to_return[$name] = $cache->data;
     }
     // Ensure that only existing configuration objects are returned, filter out
     // cached information about missing objects.
     return array_filter($data_to_return);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function readMultiple(array $names)
 {
     $list = array();
     // The names array is passed by reference and will only contain the names of
     // config object not found after the method call.
     // @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple()
     $cached_list = $this->cache->getMultiple($names);
     if (!empty($names)) {
         $list = $this->storage->readMultiple($names);
         // Cache configuration objects that were loaded from the storage, cache
         // missing configuration objects as an explicit FALSE.
         $items = array();
         foreach ($names as $name) {
             $items[$name] = array('data' => isset($list[$name]) ? $list[$name] : FALSE);
         }
         $this->cache->setMultiple($items);
     }
     // Add the configuration objects from the cache to the list.
     foreach ($cached_list as $name => $cache) {
         $list[$name] = $cache->data;
     }
     // Ensure that only existing configuration objects are returned, filter out
     // cached information about missing objects.
     return array_filter($list);
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function readMultiple(array $names)
 {
     $dataList = $this->storage->readMultiple($names);
     $result = array();
     // We also need to read the configs which are only on one of the two storages.
     foreach ($names as $name) {
         if (!isset($dataList[$name])) {
             $dataList[$name] = NULL;
         }
     }
     foreach ($dataList as $name => $data) {
         foreach ($this->filters as $filter) {
             $data = $filter->filterRead($name, $data, $this->storage);
         }
         $result[$name] = $data;
     }
     return $result;
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function getConfigDependencyManager()
 {
     $dependency_manager = new ConfigDependencyManager();
     // This uses the configuration storage directly to avoid blowing the static
     // caches in the configuration factory and the configuration entity system.
     // Additionally this ensures that configuration entity dependency discovery
     // has no dependencies on the config entity classes. Assume data with UUID
     // is a config entity. Only configuration entities can be depended on so we
     // can ignore everything else.
     $data = array_filter($this->activeStorage->readMultiple($this->activeStorage->listAll()), function ($config) {
         return isset($config['uuid']);
     });
     $dependency_manager->setData($data);
     return $dependency_manager;
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function getDefinitions()
 {
     if (!isset($this->definitions)) {
         if ($cache = $this->cache->get($this::CACHE_ID)) {
             $this->definitions = $cache->data;
         } else {
             $this->definitions = array();
             foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
                 foreach ($schema as $type => $definition) {
                     $this->definitions[$type] = $definition;
                 }
             }
             $this->cache->set($this::CACHE_ID, $this->definitions);
         }
     }
     return $this->definitions;
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function findMissingContentDependencies()
 {
     $content_dependencies = array();
     $missing_dependencies = array();
     foreach ($this->activeStorage->readMultiple($this->activeStorage->listAll()) as $config_data) {
         if (isset($config_data['dependencies']['content'])) {
             $content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['content']);
         }
     }
     foreach (array_unique($content_dependencies) as $content_dependency) {
         // Format of the dependency is entity_type:bundle:uuid.
         list($entity_type, $bundle, $uuid) = explode(':', $content_dependency, 3);
         if (!$this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
             $missing_dependencies[$uuid] = array('entity_type' => $entity_type, 'bundle' => $bundle, 'uuid' => $uuid);
         }
     }
     return $missing_dependencies;
 }
 /**
  * {@inheritdoc}
  */
 public function loadMultiple(array $names)
 {
     $list = array();
     foreach ($names as $key => $name) {
         // @todo: Deleted configuration stays in $this->cache, only return
         //   configuration objects that are not new.
         $cache_key = $this->getConfigCacheKey($name);
         if (isset($this->cache[$cache_key]) && !$this->cache[$cache_key]->isNew()) {
             $list[$name] = $this->cache[$cache_key];
             unset($names[$key]);
         }
     }
     // Pre-load remaining configuration files.
     if (!empty($names)) {
         // Initialise override information.
         $module_overrides = array();
         $storage_data = $this->storage->readMultiple($names);
         if ($this->useOverrides && !empty($storage_data)) {
             // Only get module overrides if we have configuration to override.
             $module_overrides = $this->loadOverrides($names);
         }
         foreach ($storage_data as $name => $data) {
             $cache_key = $this->getConfigCacheKey($name);
             $this->cache[$cache_key] = new Config($name, $this->storage, $this->eventDispatcher, $this->typedConfigManager);
             $this->cache[$cache_key]->initWithData($data);
             if ($this->useOverrides) {
                 if (isset($module_overrides[$name])) {
                     $this->cache[$cache_key]->setModuleOverride($module_overrides[$name]);
                 }
                 if (isset($GLOBALS['config'][$name])) {
                     $this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]);
                 }
             }
             $list[$name] = $this->cache[$cache_key];
         }
     }
     return $list;
 }
Пример #11
0
 /**
  * Returns a list of configuration objects for the given names.
  *
  * @param array $names
  *   List of names of configuration objects.
  * @param bool $immutable
  *   (optional) Create an immutable configuration objects. Defaults to TRUE.
  *
  * @return \Drupal\Core\Config\Config[]|\Drupal\Core\Config\ImmutableConfig[]
  *   List of successfully loaded configuration objects, keyed by name.
  */
 protected function doLoadMultiple(array $names, $immutable = TRUE)
 {
     $list = array();
     foreach ($names as $key => $name) {
         $cache_key = $this->getConfigCacheKey($name, $immutable);
         if (isset($this->cache[$cache_key])) {
             $list[$name] = $this->cache[$cache_key];
             unset($names[$key]);
         }
     }
     // Pre-load remaining configuration files.
     if (!empty($names)) {
         // Initialise override information.
         $module_overrides = array();
         $storage_data = $this->storage->readMultiple($names);
         if ($immutable && !empty($storage_data)) {
             // Only get module overrides if we have configuration to override.
             $module_overrides = $this->loadOverrides($names);
         }
         foreach ($storage_data as $name => $data) {
             $cache_key = $this->getConfigCacheKey($name, $immutable);
             $this->cache[$cache_key] = $this->createConfigObject($name, $immutable);
             $this->cache[$cache_key]->initWithData($data);
             if ($immutable) {
                 if (isset($module_overrides[$name])) {
                     $this->cache[$cache_key]->setModuleOverride($module_overrides[$name]);
                 }
                 if (isset($GLOBALS['config'][$name])) {
                     $this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]);
                 }
             }
             $this->propagateConfigOverrideCacheability($cache_key, $name);
             $list[$name] = $this->cache[$cache_key];
         }
     }
     return $list;
 }