3 namespace Drupal\Core\Config\Schema;
5 use Drupal\Core\Config\TypedConfigManagerInterface;
6 use Drupal\Core\TypedData\TypedData;
7 use Drupal\Core\TypedData\TypedDataManagerInterface;
10 * Defines a generic configuration element.
12 abstract class Element extends TypedData {
15 * The configuration value.
22 * Gets the typed configuration manager.
24 * Overrides \Drupal\Core\TypedData\TypedDataTrait::getTypedDataManager() to
25 * ensure the typed configuration manager is returned.
27 * @return \Drupal\Core\Config\TypedConfigManagerInterface
28 * The typed configuration manager.
30 public function getTypedDataManager() {
31 if (empty($this->typedDataManager)) {
32 $this->setTypedDataManager(\Drupal::service('config.typed'));
35 return $this->typedDataManager;
39 * Sets the typed config manager.
41 * Overrides \Drupal\Core\TypedData\TypedDataTrait::setTypedDataManager() to
42 * ensure that only typed configuration manager can be used.
44 * @param \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data_manager
45 * The typed config manager. This must be an instance of
46 * \Drupal\Core\Config\TypedConfigManagerInterface. If it is not, then this
47 * method will error when assertions are enabled. We can not narrow the
48 * typehint as this will cause PHP errors.
52 public function setTypedDataManager(TypedDataManagerInterface $typed_data_manager) {
53 assert($typed_data_manager instanceof TypedConfigManagerInterface, '$typed_data_manager should be an instance of \Drupal\Core\Config\TypedConfigManagerInterface.');
54 $this->typedDataManager = $typed_data_manager;