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;
* 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');
}
/**
*/
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);
}
/**
$definition += [
'definition_class' => '\Drupal\Core\TypedData\DataDefinition',
'type' => $type,
+ 'unwrap_for_canonical_representation' => TRUE,
];
return $definition;
}
}
}
+ /**
+ * {@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);
+ }
+
}