diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 0a93f0c..f04bbe0 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -11,8 +11,9 @@ use Drupal\Component\Utility\String; use Drupal\Core\Config\ConfigNameException; use Drupal\Core\Config\Context\ContextInterface; -use Drupal\Core\Config\TypedConfigManager; use Drupal\Core\TypedData\PrimitiveInterface; +use Drupal\Core\TypedData\Type\FloatInterface; +use Drupal\Core\TypedData\Type\IntegerInterface; /** * Defines the default configuration object. @@ -522,6 +523,9 @@ protected function getSchemaWrapper() { * A string that maps to a key within the configuration data. * * @return \Drupal\Core\Config\Schema\Element + * + * @throws \Drupal\Core\Config\ConfigException + * Thrown when schema is incomplete. */ protected function getSchemaForKey($key) { $parts = explode('.', $key); @@ -567,7 +571,7 @@ protected function castValue($key, $value) { // we have to special case the meaning of an empty string for numeric // types. In PHP this would be casted to a 0 but for the purposes of // configuration we need to treat this as a NULL. - if ($element->isNumericType() && $value === '') { + if ($value === '' && ($element instanceof IntegerInterface || $element instanceof FloatInterface)) { $value = NULL; } else { diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Float.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Float.php index f8a8120..029df13 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Float.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Float.php @@ -31,11 +31,4 @@ class Float extends PrimitiveBase implements FloatInterface { public function getCastedValue() { return (float) $this->value; } - - /** - * @inheritdoc - */ - public function isNumericType() { - return TRUE; - } } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Integer.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Integer.php index 58d902b..1f92fc9 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Integer.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Integer.php @@ -31,11 +31,4 @@ class Integer extends PrimitiveBase implements IntegerInterface { public function getCastedValue() { return (int) $this->value; } - - /** - * @inheritdoc - */ - public function isNumericType() { - return TRUE; - } } diff --git a/core/lib/Drupal/Core/TypedData/PrimitiveBase.php b/core/lib/Drupal/Core/TypedData/PrimitiveBase.php index 6d24cfb..dae6dbe 100644 --- a/core/lib/Drupal/Core/TypedData/PrimitiveBase.php +++ b/core/lib/Drupal/Core/TypedData/PrimitiveBase.php @@ -36,11 +36,4 @@ public function setValue($value, $notify = TRUE) { $this->parent->onChange($this->name); } } - - /** - * @inheritdoc - */ - public function isNumericType() { - return FALSE; - } } diff --git a/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php b/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php index d7060f6..01ad0d9 100644 --- a/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php +++ b/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php @@ -34,11 +34,4 @@ public function setValue($value); * @return mixed */ public function getCastedValue(); - - /** - * Returns TRUE if the primitive data type is numeric. - * - * @return bool - */ - public function isNumericType(); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php index 763b102..663b456 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -7,7 +7,6 @@ namespace Drupal\config\Tests; -use Drupal\Core\Config\TypedConfig; use Drupal\Core\TypedData\Type\IntegerInterface; use Drupal\Core\TypedData\Type\StringInterface; use Drupal\simpletest\DrupalUnitTestBase;