Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Config / TypedConfigManager.php
index 22795ad6fffdc4554a568de3ffa25cd1a4c4620d..c6ddfb5e9c467e9f3f98dd8a0d54e486ac561ab3 100644 (file)
@@ -6,6 +6,7 @@ use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
 use Drupal\Core\Config\Schema\ConfigSchemaDiscovery;
+use Drupal\Core\DependencyInjection\ClassResolverInterface;
 use Drupal\Core\Config\Schema\Undefined;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\TypedData\TypedDataManager;
@@ -45,13 +46,18 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
    *   The storage object to use for reading schema data
    * @param \Drupal\Core\Cache\CacheBackendInterface $cache
    *   The cache backend to use for caching the definitions.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler.
+   * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver
+   *   (optional) The class resolver.
    */
-  public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, CacheBackendInterface $cache, ModuleHandlerInterface $module_handler) {
+  public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, CacheBackendInterface $cache, ModuleHandlerInterface $module_handler, ClassResolverInterface $class_resolver = NULL) {
     $this->configStorage = $configStorage;
     $this->schemaStorage = $schemaStorage;
     $this->setCacheBackend($cache, 'typed_config_definitions');
     $this->alterInfo('config_schema_info');
     $this->moduleHandler = $module_handler;
+    $this->classResolver = $class_resolver ?: \Drupal::service('class_resolver');
   }
 
   /**
@@ -69,9 +75,7 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
    */
   public function get($name) {
     $data = $this->configStorage->read($name);
-    $type_definition = $this->getDefinition($name);
-    $data_definition = $this->buildDataDefinition($type_definition, $data);
-    return $this->create($data_definition, $data);
+    return $this->createFromNameAndData($name, $data);
   }
 
   /**
@@ -184,6 +188,7 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
     $definition += [
       'definition_class' => '\Drupal\Core\TypedData\DataDefinition',
       'type' => $type,
+      'unwrap_for_canonical_representation' => TRUE,
     ];
     return $definition;
   }
@@ -380,4 +385,13 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function createFromNameAndData($config_name, array $config_data) {
+    $definition = $this->getDefinition($config_name);
+    $data_definition = $this->buildDataDefinition($definition, $config_data);
+    return $this->create($data_definition, $config_data);
+  }
+
 }