diff --git a/core/lib/Drupal/Core/TypedData/Type/Date.php b/core/lib/Drupal/Core/TypedData/Type/Date.php index 37a55ff..e326674 100644 --- a/core/lib/Drupal/Core/TypedData/Type/Date.php +++ b/core/lib/Drupal/Core/TypedData/Type/Date.php @@ -42,11 +42,4 @@ public function setValue($value) { $this->value = $value instanceOf DrupalDateTime ? $value : new DrupalDateTime($value); } } - - /** - * Overrides TypedDataInterface::getString(). - */ - public function getString() { - return (string) $this->getValue(); - } } diff --git a/core/lib/Drupal/Core/TypedData/Type/Duration.php b/core/lib/Drupal/Core/TypedData/Type/Duration.php index 985d38d..fa539cf 100644 --- a/core/lib/Drupal/Core/TypedData/Type/Duration.php +++ b/core/lib/Drupal/Core/TypedData/Type/Duration.php @@ -32,6 +32,7 @@ class Duration extends TypedData { * Overrides TypedData::setValue(). */ public function setValue($value) { + // Catch any exceptions thrown due to invalid values being passed. try { if ($value instanceof DateInterval || !isset($value)) { $this->value = $value; diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index eb25001..5177f09 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -47,8 +47,6 @@ public function __construct() { $this->discovery = new AlterDecorator($this->discovery, 'validation_constraint'); $this->discovery = new CacheDecorator($this->discovery, 'validation_constraints:' . language(LANGUAGE_TYPE_INTERFACE)->langcode); - // We overrode getDefinition() and getDefinitions() so we must pass the - // PluginManager and not just discovery. $this->factory = new DefaultFactory($this); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 5f93835..6b10de6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -335,7 +335,7 @@ protected function assertIntrospection($entity_type) { 'constraints' => array( 'EntityType' => $entity_type, ), - 'label' => t('Test entity'), + 'label' => 'Test entity', ); $wrapped_entity = typed_data()->create($definition); $definitions = $wrapped_entity->getPropertyDefinitions($definition); @@ -455,7 +455,7 @@ protected function assertDataStructureInterfaces($entity_type) { 'constraints' => array( 'EntityType' => $entity_type, ), - 'label' => t('Test entity'), + 'label' => 'Test entity', ); $wrapped_entity = typed_data()->create($entity_definition, $entity); @@ -514,7 +514,7 @@ public function testEntityConstraintValidation() { 'constraints' => array( 'EntityType' => 'entity_test', ), - 'label' => t('Test entity'), + 'label' => 'Test entity', ); $wrapped_entity = typed_data()->create($entity_definition, $entity); @@ -535,7 +535,7 @@ public function testEntityConstraintValidation() { 'EntityType' => 'node', 'Bundle' => 'article', ), - 'label' => t('Test entity'), + 'label' => 'Test node', ); $wrapped_entity = typed_data()->create($entity_definition, $node); @@ -543,7 +543,7 @@ public function testEntityConstraintValidation() { $this->assertEqual($violations->count(), 1); $node->type = 'article'; - node_save($node); + $node->save(); $wrapped_entity->setValue($node); $violations = $wrapped_entity->validate(); $this->assertEqual($violations->count(), 0); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 6c69294..2c97b0a 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -176,6 +176,7 @@ function hook_data_type_info() { 'label' => t('Email'), 'class' => '\Drupal\email\Type\Email', 'primitive type' => \Drupal\Core\TypedData\Primitive::String, + 'constraints' => array('Email' => array()), ), ); }