From 12f895ec3964554fbcf449e7ada638ecb572ee22 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Thu, 26 Dec 2013 14:22:40 -0800 Subject: [PATCH] Issue #2132145 by plopesc, amateescu, Xano: Rename 'typed_data' / Drupal::typedData() to 'typed_data_manager' / Drupal::typedDataManager. --- core/core.services.yml | 2 +- core/lib/Drupal.php | 4 +- .../Drupal/Core/Entity/ContentEntityBase.php | 4 +- .../FieldableEntityStorageControllerBase.php | 2 +- .../Core/Executable/ExecutablePluginBase.php | 2 +- .../Drupal/Core/Field/ConfigFieldItemList.php | 2 +- .../lib/Drupal/Core/Field/FieldDefinition.php | 2 +- core/lib/Drupal/Core/Field/FieldItemBase.php | 2 +- .../Drupal/Core/Plugin/Context/Context.php | 2 +- .../Core/TypedData/Annotation/DataType.php | 2 +- .../Core/TypedData/DataReferenceBase.php | 2 +- .../Drupal/Core/TypedData/ListDefinition.php | 2 +- .../TypedData/Plugin/DataType/ItemList.php | 2 +- .../Core/TypedData/Plugin/DataType/Map.php | 2 +- core/lib/Drupal/Core/TypedData/TypedData.php | 6 +-- .../Core/TypedData/TypedDataManager.php | 2 +- .../Drupal/email/ConfigurableEmailItem.php | 2 +- core/modules/field/field.info.inc | 2 +- .../Plugin/Field/FieldType/TestItem.php | 2 +- .../Drupal/field_ui/Form/FieldEditForm.php | 10 ++--- .../lib/Drupal/filter/Tests/FilterAPITest.php | 2 +- .../Plugin/Field/FieldType/NumberItemBase.php | 2 +- .../Tests/Normalizer/ListNormalizerTest.php | 4 +- .../system/Tests/Entity/EntityFieldTest.php | 8 ++-- .../system/Tests/TypedData/TypedDataTest.php | 38 +++++++++---------- .../Plugin/Field/FieldType/TelephoneItem.php | 2 +- .../text/Plugin/Field/FieldType/TextItem.php | 2 +- core/modules/user/user.module | 2 +- 28 files changed, 58 insertions(+), 58 deletions(-) diff --git a/core/core.services.yml b/core/core.services.yml index 8f2965aa08f6..ba3be7f07c2a 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -248,7 +248,7 @@ services: factory_class: Drupal\Core\Database\Database factory_method: getConnection arguments: [slave] - typed_data: + typed_data_manager: class: Drupal\Core\TypedData\TypedDataManager parent: default_plugin_manager calls: diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 6bb8179ffa3f..9c14801723cb 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -366,8 +366,8 @@ public static function moduleHandler() { * * @see \Drupal\Core\TypedData\TypedDataManager::create() */ - public static function typedData() { - return static::$container->get('typed_data'); + public static function typedDataManager() { + return static::$container->get('typed_data_manager'); } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 3564f1fff741..8bdaed831078 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -261,7 +261,7 @@ public function getString() { */ public function validate() { // @todo: Add the typed data manager as proper dependency. - return \Drupal::typedData()->getValidator()->validate($this); + return \Drupal::typedDataManager()->getValidator()->validate($this); } /** @@ -414,7 +414,7 @@ protected function getTranslatedField($name, $langcode) { if (isset($this->values[$name][$langcode])) { $value = $this->values[$name][$langcode]; } - $field = \Drupal::typedData()->getPropertyInstance($this, $name, $value); + $field = \Drupal::typedDataManager()->getPropertyInstance($this, $name, $value); if ($default) { // $this->defaultLangcode might not be set if we are initializing the // default language code cache, in which case there is no valid diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php index b89625dc9a5d..d30c972544be 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php @@ -266,7 +266,7 @@ public function onBundleDelete($bundle) { } */ public function onFieldItemsPurge(EntityInterface $entity, FieldInstanceInterface $instance) { if ($values = $this->readFieldItemsToPurge($entity, $instance)) { - $items = \Drupal::typedData()->create($instance, $values, $instance->getName(), $entity); + $items = \Drupal::typedDataManager()->create($instance, $values, $instance->getName(), $entity); $items->delete(); } $this->purgeFieldItems($entity, $instance); diff --git a/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php index 36b11c4cfa97..e2d7bd3d577c 100644 --- a/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php +++ b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php @@ -95,7 +95,7 @@ public function getConfig() { */ public function setConfig($key, $value) { if ($definition = $this->getConfigDefinition($key)) { - $typed_data = \Drupal::typedData()->create($definition, $value); + $typed_data = \Drupal::typedDataManager()->create($definition, $value); if ($typed_data->validate()->count() > 0) { throw new PluginException("The provided configuration value does not pass validation."); diff --git a/core/lib/Drupal/Core/Field/ConfigFieldItemList.php b/core/lib/Drupal/Core/Field/ConfigFieldItemList.php index 0da28d0b6e0d..ec9c4ea3755f 100644 --- a/core/lib/Drupal/Core/Field/ConfigFieldItemList.php +++ b/core/lib/Drupal/Core/Field/ConfigFieldItemList.php @@ -66,7 +66,7 @@ public function getConstraints() { // widgets. $cardinality = $this->getFieldDefinition()->getCardinality(); if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) { - $constraints[] = \Drupal::typedData() + $constraints[] = \Drupal::typedDataManager() ->getValidationConstraintManager() ->create('Count', array( 'max' => $cardinality, diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php index 0829820b1843..882d086f4ad2 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinition.php +++ b/core/lib/Drupal/Core/Field/FieldDefinition.php @@ -108,7 +108,7 @@ public function setSetting($setting_name, $value) { * {@inheritdoc} */ public function getPropertyNames() { - return array_keys(\Drupal::typedData()->create($this->getItemDefinition())->getPropertyDefinitions()); + return array_keys(\Drupal::typedDataManager()->create($this->getItemDefinition())->getPropertyDefinitions()); } /** diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 08b2f59e75db..b5b0f3f457b9 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -32,7 +32,7 @@ public function __construct(DataDefinitionInterface $definition, $name = NULL, T // with the whole item. foreach ($this->getPropertyDefinitions() as $name => $definition) { if ($definition->isComputed()) { - $this->properties[$name] = \Drupal::typedData()->getPropertyInstance($this, $name); + $this->properties[$name] = \Drupal::typedDataManager()->getPropertyInstance($this, $name); } } } diff --git a/core/lib/Drupal/Core/Plugin/Context/Context.php b/core/lib/Drupal/Core/Plugin/Context/Context.php index 1fe46a71620c..2d79d6f441df 100644 --- a/core/lib/Drupal/Core/Plugin/Context/Context.php +++ b/core/lib/Drupal/Core/Plugin/Context/Context.php @@ -46,7 +46,7 @@ public function getContextValue() { public function setContextValue($value) { // Make sure the value set is a typed data object. if (!empty($this->contextDefinition['type']) && !$value instanceof TypedDataInterface) { - $value = \Drupal::typedData()->create(new DataDefinition($this->contextDefinition), $value); + $value = \Drupal::typedDataManager()->create(new DataDefinition($this->contextDefinition), $value); } parent::setContextValue($value); } diff --git a/core/lib/Drupal/Core/TypedData/Annotation/DataType.php b/core/lib/Drupal/Core/TypedData/Annotation/DataType.php index d47fb9e4a0a4..c95063c69015 100644 --- a/core/lib/Drupal/Core/TypedData/Annotation/DataType.php +++ b/core/lib/Drupal/Core/TypedData/Annotation/DataType.php @@ -28,7 +28,7 @@ * type, is ordered and may contain duplicates. The class used for a list of * items of a certain type may be specified using the 'list class' key. * - * @see \Drupal::typedData() + * @see \Drupal::typedDataManager() * @see \Drupal\Core\TypedData\TypedDataManager::create() * @see hook_data_type_info_alter() * diff --git a/core/lib/Drupal/Core/TypedData/DataReferenceBase.php b/core/lib/Drupal/Core/TypedData/DataReferenceBase.php index 22d8f3223406..5a2d5977f358 100644 --- a/core/lib/Drupal/Core/TypedData/DataReferenceBase.php +++ b/core/lib/Drupal/Core/TypedData/DataReferenceBase.php @@ -43,7 +43,7 @@ public function getValue() { * {@inheritdoc} */ public function setValue($value, $notify = TRUE) { - $this->target = \Drupal::typedData()->create($this->getTargetDefinition(), $value); + $this->target = \Drupal::typedDataManager()->create($this->getTargetDefinition(), $value); // Notify the parent of any changes. if ($notify && isset($this->parent)) { $this->parent->onChange($this->name); diff --git a/core/lib/Drupal/Core/TypedData/ListDefinition.php b/core/lib/Drupal/Core/TypedData/ListDefinition.php index 231a0fc6ae28..4963107bac3b 100644 --- a/core/lib/Drupal/Core/TypedData/ListDefinition.php +++ b/core/lib/Drupal/Core/TypedData/ListDefinition.php @@ -69,7 +69,7 @@ public function getClass() { else { // If a list definition is used but no class has been specified, derive // the default list class from the item type. - $item_type_definition = \Drupal::typedData() + $item_type_definition = \Drupal::typedDataManager() ->getDefinition($this->getItemDefinition()->getDataType()); return $item_type_definition['list_class']; } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php index 89d2cd8584d2..2e906d0e1d7a 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php @@ -137,7 +137,7 @@ public function offsetGet($offset) { * @return \Drupal\Core\TypedData\TypedDataInterface */ protected function createItem($offset = 0, $value = NULL) { - return \Drupal::typedData()->getPropertyInstance($this, $offset, $value); + return \Drupal::typedDataManager()->getPropertyInstance($this, $offset, $value); } /** diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php index 100f4243ff02..ab66442535e3 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php @@ -119,7 +119,7 @@ public function get($property_name) { $value = $this->values[$property_name]; } // If the property is unknown, this will throw an exception. - $this->properties[$property_name] = \Drupal::typedData()->getPropertyInstance($this, $property_name, $value); + $this->properties[$property_name] = \Drupal::typedDataManager()->getPropertyInstance($this, $property_name, $value); } return $this->properties[$property_name]; } diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php index bf5f787e7e98..1597c93033f5 100644 --- a/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -73,7 +73,7 @@ public function getPluginId() { * {@inheritdoc} */ public function getPluginDefinition() { - return \Drupal::typedData()->getDefinition($this->definition->getDataType()); + return \Drupal::typedDataManager()->getDefinition($this->definition->getDataType()); } /** @@ -113,7 +113,7 @@ public function getString() { */ public function getConstraints() { // @todo: Add the typed data manager as proper dependency. - return \Drupal::typedData()->getConstraints($this->definition); + return \Drupal::typedDataManager()->getConstraints($this->definition); } /** @@ -121,7 +121,7 @@ public function getConstraints() { */ public function validate() { // @todo: Add the typed data manager as proper dependency. - return \Drupal::typedData()->getValidator()->validate($this); + return \Drupal::typedDataManager()->getValidator()->validate($this); } /** diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index f2bd59f05334..e060cd305368 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -109,7 +109,7 @@ public function createInstance($data_type, array $configuration) { * @return \Drupal\Core\TypedData\TypedDataInterface * The instantiated typed data object. * - * @see \Drupal::typedData() + * @see \Drupal::typedDataManager() * @see \Drupal\Core\TypedData\TypedDataManager::getPropertyInstance() * @see \Drupal\Core\TypedData\Plugin\DataType\Integer * @see \Drupal\Core\TypedData\Plugin\DataType\Float diff --git a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php index e61b39bd7092..48e90ec769e6 100644 --- a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php +++ b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php @@ -49,7 +49,7 @@ public static function schema(FieldInterface $field) { * {@inheritdoc} */ public function getConstraints() { - $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); + $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); $constraints[] = $constraint_manager->create('ComplexData', array( diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 5b1e81a4741b..d33b2df11a4b 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -36,7 +36,7 @@ function field_info_cache_clear() { entity_info_cache_clear(); // Clear typed data definitions. - \Drupal::typedData()->clearCachedDefinitions(); + \Drupal::typedDataManager()->clearCachedDefinitions(); \Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions(); \Drupal::service('config.factory')->reset(); diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php index 18e6bf4ca936..ed8f38ab27fa 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php @@ -128,7 +128,7 @@ public function delete() { * {@inheritdoc} */ public function getConstraints() { - $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); + $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); $constraints[] = $constraint_manager->create('ComplexData', array( diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php index 2a788cb63f26..46fe3de3e59d 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php @@ -46,7 +46,7 @@ class FieldEditForm extends FormBase { * * @var \Drupal\Core\TypedData\TypedDataManager */ - protected $typedData; + protected $typedDataManager; /** * {@inheritdoc} @@ -62,13 +62,13 @@ public function getFormId() { * The entity manager. * @param \Drupal\field\FieldInfo $field_info * The field info service. - * @param \Drupal\Core\TypedData\TypedDataManager $typed_data + * @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager * The typed data manager. */ - public function __construct(EntityManagerInterface $entity_manager, FieldInfo $field_info, TypedDataManager $typed_data) { + public function __construct(EntityManagerInterface $entity_manager, FieldInfo $field_info, TypedDataManager $typed_data_manager) { $this->entityManager = $entity_manager; $this->fieldInfo = $field_info; - $this->typedData = $typed_data; + $this->typedDataManager = $typed_data_manager; } /** @@ -78,7 +78,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), $container->get('field.info'), - $container->get('typed_data') + $container->get('typed_data_manager') ); } diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAPITest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAPITest.php index 6d7bc8eb17a0..6d39f4112a90 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAPITest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAPITest.php @@ -193,7 +193,7 @@ function testFilterFormatAPI() { */ function testTypedDataAPI() { $definition = DataDefinition::create('filter_format'); - $data = \Drupal::typedData()->create($definition); + $data = \Drupal::typedDataManager()->create($definition); $this->assertTrue($data instanceof AllowedValuesInterface, 'Typed data object implements \Drupal\Core\TypedData\AllowedValuesInterface'); diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php index 0f33b42f6f43..e8630be35f6b 100644 --- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php +++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php @@ -74,7 +74,7 @@ public function isEmpty() { * {@inheritdoc} */ public function getConstraints() { - $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); + $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); $settings = $this->getFieldSettings(); diff --git a/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php index 988d04ec2d80..2462b4af8893 100644 --- a/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php +++ b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php @@ -62,14 +62,14 @@ public function setUp() { ->method('getPropertyInstance') ->will($this->returnValue($typed_data)); - // Set up a mock container as ItemList() will call for the 'typed_data' + // Set up a mock container as ItemList() will call for the 'typed_data_manager' // service. $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder') ->setMethods(array('get')) ->getMock(); $container->expects($this->any()) ->method('get') - ->with($this->equalTo('typed_data')) + ->with($this->equalTo('typed_data_manager')) ->will($this->returnValue($typed_data_manager)); \Drupal::setContainer($container); 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 1e777a62d0ea..536e3b188bcb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -519,13 +519,13 @@ public function getContainedStrings(TypedDataInterface $wrapper, $depth, array & * Makes sure data types are correctly derived for all entity types. */ public function testDataTypes() { - $types = \Drupal::typedData()->getDefinitions(); + $types = \Drupal::typedDataManager()->getDefinitions(); foreach (entity_test_entity_types() as $entity_type) { $this->assertTrue($types['entity:' . $entity_type]['class'], 'Entity data type registed.'); } // Check bundle types are provided as well. entity_test_create_bundle('bundle'); - $types = \Drupal::typedData()->getDefinitions(); + $types = \Drupal::typedDataManager()->getDefinitions(); $this->assertTrue($types['entity:entity_test:bundle']['class'], 'Entity bundle data type registed.'); } @@ -539,7 +539,7 @@ public function testEntityConstraintValidation() { $definition = FieldDefinition::create('entity_reference') ->setLabel('Test entity') ->setSetting('target_type', 'entity_test'); - $reference_field_item = \Drupal::TypedData()->create($definition); + $reference_field_item = \Drupal::typedDataManager()->create($definition); $reference = $reference_field_item->get('entity'); $reference->setValue($entity); @@ -565,7 +565,7 @@ public function testEntityConstraintValidation() { 'target_type' => 'node', 'target_bundle' => 'article', )); - $reference_field_item = \Drupal::TypedData()->create($definition); + $reference_field_item = \Drupal::TypedDataManager()->create($definition); $reference = $reference_field_item->get('entity'); $reference->setValue($node); $violations = $reference->validate(); diff --git a/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php index 90a7229f71c2..eeb6bb5ceeb8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php @@ -23,7 +23,7 @@ class TypedDataTest extends DrupalUnitTestBase { * * @var \Drupal\Core\TypedData\TypedDataManager */ - protected $typedData; + protected $typedDataManager; /** * Modules to enable. @@ -44,7 +44,7 @@ public function setUp() { parent::setup(); $this->installSchema('file', array('file_managed', "file_usage")); - $this->typedData = $this->container->get('typed_data'); + $this->typedDataManager = $this->container->get('typed_data_manager'); } /** @@ -56,7 +56,7 @@ protected function createTypedData($definition, $value = NULL, $name = NULL) { if (is_array($definition)) { $definition = DataDefinition::create($definition['type']); } - $data = $this->typedData->create($definition, $value, $name); + $data = $this->typedDataManager->create($definition, $value, $name); $this->assertTrue($data instanceof \Drupal\Core\TypedData\TypedDataInterface, 'Typed data object is an instance of the typed data interface.'); return $data; } @@ -507,10 +507,10 @@ public function testTypedDataValidation() { ->setConstraints(array( 'Range' => array('min' => 5), )); - $violations = $this->typedData->create($definition, 10)->validate(); + $violations = $this->typedDataManager->create($definition, 10)->validate(); $this->assertEqual($violations->count(), 0); - $integer = $this->typedData->create($definition, 1); + $integer = $this->typedDataManager->create($definition, 1); $violations = $integer->validate(); $this->assertEqual($violations->count(), 1); @@ -525,7 +525,7 @@ public function testTypedDataValidation() { ->setConstraints(array( 'Length' => array('min' => 10), )); - $violations = $this->typedData->create($definition, "short")->validate(); + $violations = $this->typedDataManager->create($definition, "short")->validate(); $this->assertEqual($violations->count(), 1); $message = t('This value is too short. It should have %limit characters or more.', array('%limit' => 10)); $this->assertEqual($violations[0]->getMessage(), $message, 'Translated violation message retrieved.'); @@ -536,46 +536,46 @@ public function testTypedDataValidation() { 'Range' => array('min' => 5), 'Null' => array(), )); - $violations = $this->typedData->create($definition, 10)->validate(); + $violations = $this->typedDataManager->create($definition, 10)->validate(); $this->assertEqual($violations->count(), 1); - $violations = $this->typedData->create($definition, 1)->validate(); + $violations = $this->typedDataManager->create($definition, 1)->validate(); $this->assertEqual($violations->count(), 2); // Test validating property containers and make sure the NotNull and Null // constraints work with typed data containers. $definition = FieldDefinition::create('integer') ->setConstraints(array('NotNull' => array())); - $field_item = $this->typedData->create($definition, array('value' => 10)); + $field_item = $this->typedDataManager->create($definition, array('value' => 10)); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 0); - $field_item = $this->typedData->create($definition, array('value' => 'no integer')); + $field_item = $this->typedDataManager->create($definition, array('value' => 'no integer')); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 1); $this->assertEqual($violations[0]->getPropertyPath(), '0.value'); // Test that the field item may not be empty. - $field_item = $this->typedData->create($definition); + $field_item = $this->typedDataManager->create($definition); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 1); // Test the Null constraint with typed data containers. $definition = FieldDefinition::create('float') ->setConstraints(array('Null' => array())); - $field_item = $this->typedData->create($definition, array('value' => 11.5)); + $field_item = $this->typedDataManager->create($definition, array('value' => 11.5)); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 1); - $field_item = $this->typedData->create($definition); + $field_item = $this->typedDataManager->create($definition); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 0); // Test getting constraint definitions by type. - $definitions = $this->typedData->getValidationConstraintManager()->getDefinitionsByType('entity'); + $definitions = $this->typedDataManager->getValidationConstraintManager()->getDefinitionsByType('entity'); $this->assertTrue(isset($definitions['EntityType']), 'Constraint plugin found for type entity.'); $this->assertTrue(isset($definitions['Null']), 'Constraint plugin found for type entity.'); $this->assertTrue(isset($definitions['NotNull']), 'Constraint plugin found for type entity.'); - $definitions = $this->typedData->getValidationConstraintManager()->getDefinitionsByType('string'); + $definitions = $this->typedDataManager->getValidationConstraintManager()->getDefinitionsByType('string'); $this->assertFalse(isset($definitions['EntityType']), 'Constraint plugin not found for type string.'); $this->assertTrue(isset($definitions['Null']), 'Constraint plugin found for type string.'); $this->assertTrue(isset($definitions['NotNull']), 'Constraint plugin found for type string.'); @@ -583,17 +583,17 @@ public function testTypedDataValidation() { // Test automatic 'required' validation. $definition = DataDefinition::create('integer') ->setRequired(TRUE); - $violations = $this->typedData->create($definition)->validate(); + $violations = $this->typedDataManager->create($definition)->validate(); $this->assertEqual($violations->count(), 1); - $violations = $this->typedData->create($definition, 0)->validate(); + $violations = $this->typedDataManager->create($definition, 0)->validate(); $this->assertEqual($violations->count(), 0); // Test validating a list of a values and make sure property paths starting // with "0" are created. $definition = FieldDefinition::create('integer'); - $violations = $this->typedData->create($definition, array(array('value' => 10)))->validate(); + $violations = $this->typedDataManager->create($definition, array(array('value' => 10)))->validate(); $this->assertEqual($violations->count(), 0); - $violations = $this->typedData->create($definition, array(array('value' => 'string')))->validate(); + $violations = $this->typedDataManager->create($definition, array(array('value' => 'string')))->validate(); $this->assertEqual($violations->count(), 1); $this->assertEqual($violations[0]->getInvalidValue(), 'string'); diff --git a/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php index 8581bdf3a5a9..e55fd523390c 100644 --- a/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php +++ b/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php @@ -69,7 +69,7 @@ public function isEmpty() { * {@inheritdoc} */ public function getConstraints() { - $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); + $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); $max_length = 256; diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php index cd783f9605c9..ffa1edf7d11f 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php @@ -55,7 +55,7 @@ public static function schema(FieldInterface $field) { * {@inheritdoc} */ public function getConstraints() { - $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); + $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); if ($max_length = $this->getFieldSetting('max_length')) { diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 31a651e8da92..cfb48f8b56de 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -337,7 +337,7 @@ function user_load_by_name($name) { function user_validate_name($name) { $definition = DataDefinition::create('string') ->setConstraints(array('UserName' => array())); - $data = \Drupal::typedData()->create($definition); + $data = \Drupal::typedDataManager()->create($definition); $data->setValue($name); $violations = $data->validate(); if (count($violations) > 0) { -- GitLab