diff --git a/core/modules/field/src/ConfigImporterFieldPurger.php b/core/modules/field/src/ConfigImporterFieldPurger.php index 43ab00e..efc39a2 100644 --- a/core/modules/field/src/ConfigImporterFieldPurger.php +++ b/core/modules/field/src/ConfigImporterFieldPurger.php @@ -141,7 +141,7 @@ public static function getFieldStoragesToPurge(array $extensions, array $deletes /** @var \Drupal\field\FieldStorageConfigInterface[] $field_storages */ $field_storages = entity_load_multiple_by_properties('field_storage_config', array('deleted' => TRUE, 'include_deleted' => TRUE)); foreach ($field_storages as $field_storage) { - if (!in_array($field_storage->getFieldTypeProvider(), $providers)) { + if (!in_array($field_storage->getTypeProvider(), $providers)) { $storages_to_delete[$field_storage->id()] = $field_storage; } } diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 4441c27..ab869db 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -320,7 +320,7 @@ protected function preSaveNew(EntityStorageInterface $storage) { public function calculateDependencies() { parent::calculateDependencies(); // Ensure the field is dependent on the providing module. - $this->addDependency('module', $this->getFieldTypeProvider()); + $this->addDependency('module', $this->getTypeProvider()); // Ensure the field is dependent on the provider of the entity type. $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); $this->addDependency('module', $entity_type->getProvider()); @@ -509,7 +509,7 @@ public function isDeleted() { /** * {@inheritdoc} */ - public function getFieldTypeProvider() { + public function getTypeProvider() { return $this->module; } @@ -564,7 +564,7 @@ public function setSetting($setting_name, $value) { /** * {@inheritdoc} */ - public function setSettings($settings) { + public function setSettings(array $settings) { $this->settings = $settings; return $this; } @@ -808,7 +808,7 @@ public function getIndexes() { /** * {@inheritdoc} */ - public function setIndexes($indexes) { + public function setIndexes(array $indexes) { $this->indexes = $indexes; return $this; } diff --git a/core/modules/field/src/FieldStorageConfigInterface.php b/core/modules/field/src/FieldStorageConfigInterface.php index bb8b080..116517a 100644 --- a/core/modules/field/src/FieldStorageConfigInterface.php +++ b/core/modules/field/src/FieldStorageConfigInterface.php @@ -24,6 +24,14 @@ public function getType(); /** + * Returns the name of the module providing the field type. + * + * @return string + * The name of the module that provides the field type. + */ + public function getTypeProvider(); + + /** * Returns the list of bundles where the field storage has fields. * * @return array @@ -32,12 +40,12 @@ public function getType(); public function getBundles(); /** - * Returns whether the field storage is locked or not. + * Returns whether the field is deleted or not. * * @return bool - * TRUE if the field storage is locked. + * TRUE if the field is deleted. */ - public function isLocked(); + public function isDeleted(); /** * Checks if the field storage can be deleted. @@ -48,6 +56,14 @@ public function isLocked(); public function isDeletable(); /** + * Returns whether the field storage is locked or not. + * + * @return bool + * TRUE if the field storage is locked. + */ + public function isLocked(); + + /** * Sets the locked flag. * * @param bool $locked @@ -58,14 +74,6 @@ public function isDeletable(); public function setLocked($locked); /** - * Returns whether the field is deleted or not. - * - * @return bool - * TRUE if the field is deleted. - */ - public function isDeleted(); - - /** * Sets the maximum number of items allowed for the field. * * @param int $cardinality @@ -95,15 +103,7 @@ public function setSetting($setting_name, $value); * * @return $this */ - public function setSettings($settings); - - /** - * Returns the name of the module providing the field type. - * - * @return string - * The name of the module that provides the field type. - */ - public function getFieldTypeProvider(); + public function setSettings(array $settings); /** * Sets whether the field is translatable. @@ -131,6 +131,6 @@ public function getIndexes(); * * @return $this */ - public function setIndexes($indexes); + public function setIndexes(array $indexes); } diff --git a/core/modules/field/src/FieldStorageConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php index 3787f88..2cb6ec8 100644 --- a/core/modules/field/src/FieldStorageConfigStorage.php +++ b/core/modules/field/src/FieldStorageConfigStorage.php @@ -145,7 +145,7 @@ public function loadByProperties(array $conditions = array()) { break; case 'module': - $checked_value = $field->getFieldTypeProvider(); + $checked_value = $field->getTypeProvider(); break; case 'type': diff --git a/core/modules/field/src/Tests/FieldCrudTest.php b/core/modules/field/src/Tests/FieldCrudTest.php index e3a1de6..33ace63 100644 --- a/core/modules/field/src/Tests/FieldCrudTest.php +++ b/core/modules/field/src/Tests/FieldCrudTest.php @@ -203,35 +203,35 @@ function testDeleteFieldCrossDeletion() { entity_test_create_bundle($field_definition_2['bundle']); // Check that deletion of a field storage deletes its fields. - $delete_this_field_storage = $this->fieldStorage; + $field_storage = $this->fieldStorage; entity_create('field_config', $this->fieldDefinition)->save(); entity_create('field_config', $field_definition_2)->save(); - $delete_this_field_storage->delete(); - $this->assertFalse(FieldConfig::loadByName('entity_test', $this->fieldDefinition['bundle'], $delete_this_field_storage->getName())); - $this->assertFalse(FieldConfig::loadByName('entity_test', $field_definition_2['bundle'], $delete_this_field_storage->getName())); + $field_storage->delete(); + $this->assertFalse(FieldConfig::loadByName('entity_test', $this->fieldDefinition['bundle'], $field_storage->getName())); + $this->assertFalse(FieldConfig::loadByName('entity_test', $field_definition_2['bundle'], $field_storage->getName())); // Check that deletion of the last field deletes the storage. - $delete_last_field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition); - $delete_last_field_storage->save(); + $field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition); + $field_storage->save(); $field = entity_create('field_config', $this->fieldDefinition); $field->save(); $field_2 = entity_create('field_config', $field_definition_2); $field_2->save(); $field->delete(); - $this->assertTrue(FieldStorageConfig::loadByName('entity_test', $delete_last_field_storage->getName())); + $this->assertTrue(FieldStorageConfig::loadByName('entity_test', $field_storage->getName())); $field_2->delete(); - $this->assertFalse(FieldStorageConfig::loadByName('entity_test', $delete_last_field_storage->getName())); + $this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName())); // Check that deletion of all fields using a storage simultaneously deletes // the storage. - $delete_all_field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition); - $delete_all_field_storage->save(); + $field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition); + $field_storage->save(); $field = entity_create('field_config', $this->fieldDefinition); $field->save(); $field_2 = entity_create('field_config', $field_definition_2); $field_2->save(); $this->container->get('entity.manager')->getStorage('field_config')->delete(array($field, $field_2)); - $this->assertFalse(FieldStorageConfig::loadByName('entity_test', $delete_all_field_storage->getName())); + $this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName())); } /** diff --git a/core/modules/field_ui/src/Form/FieldStorageEditForm.php b/core/modules/field_ui/src/Form/FieldStorageEditForm.php index d99f9cd..92ddca1 100644 --- a/core/modules/field_ui/src/Form/FieldStorageEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageEditForm.php @@ -155,7 +155,7 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf // Build the non-configurable field values. $form['field_storage']['field_name'] = array('#type' => 'value', '#value' => $field_storage->getName()); $form['field_storage']['type'] = array('#type' => 'value', '#value' => $field_storage->getType()); - $form['field_storage']['module'] = array('#type' => 'value', '#value' => $field_storage->getFieldTypeProvider()); + $form['field_storage']['module'] = array('#type' => 'value', '#value' => $field_storage->getTypeProvider()); $form['field_storage']['translatable'] = array('#type' => 'value', '#value' => $field_storage->isTranslatable()); $form['actions'] = array('#type' => 'actions'); diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 8a2d4b5..cc326b3 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -322,7 +322,6 @@ function image_filter_keyword($value, $current_pixels, $new_pixels) { * Transforms default image of image field from array into single value at save. */ function image_entity_presave(EntityInterface $entity) { - // Get the default image settings, return if not saving an image field storage // or image field entity. if (($entity instanceof FieldStorageConfigInterface || $entity instanceof FieldConfigInterface) && $entity->getType() == 'image') { diff --git a/core/modules/options/options.module b/core/modules/options/options.module index 8b7167a..d221adb 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -106,7 +106,7 @@ function options_allowed_values(FieldStorageDefinitionInterface $definition, Fie * Implements hook_field_storage_config_update_forbid(). */ function options_field_storage_config_update_forbid(FieldStorageConfigInterface $field_storage, FieldStorageConfigInterface $prior_field_storage) { - if ($field_storage->getFieldTypeProvider() == 'options' && $field_storage->hasData()) { + if ($field_storage->getTypeProvider() == 'options' && $field_storage->hasData()) { // Forbid any update that removes allowed values with actual data. $allowed_values = $field_storage->getSetting('allowed_values'); $prior_allowed_values = $prior_field_storage->getSetting('allowed_values'); diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index ec79d85..2037645 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -179,7 +179,7 @@ function views_views_data() { /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ foreach ($entity_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) { if (_views_field_get_entity_type_storage($field_storage)) { - $result = (array) $module_handler->invoke($field_storage->getFieldTypeProvider(), 'field_views_data', array($field_storage)); + $result = (array) $module_handler->invoke($field_storage->getTypeProvider(), 'field_views_data', array($field_storage)); if (empty($result)) { $result = views_field_default_views_data($field_storage); } @@ -211,7 +211,7 @@ function views_views_data_alter(&$data) { /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ foreach ($entity_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) { if (_views_field_get_entity_type_storage($field_storage)) { - $function = $field_storage->getFieldTypeProvider() . '_field_views_data_views_data_alter'; + $function = $field_storage->getTypeProvider() . '_field_views_data_views_data_alter'; if (function_exists($function)) { $function($data, $field_storage); }