diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceConfigInterface.php b/core/modules/field/lib/Drupal/field/FieldInstanceConfigInterface.php index 8157dc6..7e20bfc 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceConfigInterface.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceConfigInterface.php @@ -18,10 +18,10 @@ /** * Returns the field entity for this instance. * - * @return \Drupal\field\FieldInterface + * @return \Drupal\field\FieldConfigInterface * The field entity for this instance. */ - public function getField(); + public function getFieldConfig(); /** * Allows a bundle to be renamed. diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstanceConfig.php index 476404e..d4072e8 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstanceConfig.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\field\Plugin\Core\Entity\FieldInstance. + * Contains \Drupal\field\Plugin\Core\Entity\FieldInstanceConfig. */ namespace Drupal\field\Plugin\Core\Entity; @@ -191,7 +191,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi * * @var \Drupal\field\Plugin\Core\Entity\FieldConfig */ - protected $field_config; + protected $fieldConfig; /** * Flag indicating whether the bundle name can be renamed or not. @@ -258,7 +258,7 @@ public function __construct(array $values, $entity_type = 'field_instance_config // At this point, we should have a 'field_uuid' and a FieldConfig. Ditch the // 'field_name' property if it was provided, and assign the $field property. unset($values['field_name']); - $this->field_config = $field; + $this->fieldConfig = $field; // Discard the 'field_type' entry that is added in config records to ease // schema generation. See getExportProperties(). @@ -266,16 +266,16 @@ public function __construct(array $values, $entity_type = 'field_instance_config // Check required properties. if (empty($values['entity_type'])) { - throw new FieldException(format_string('Attempt to create an instance of field @field_id without an entity type.', array('@field_id' => $this->field_config->id))); + throw new FieldException(format_string('Attempt to create an instance of field @field_id without an entity type.', array('@field_id' => $this->fieldConfig->id))); } if (empty($values['bundle'])) { - throw new FieldException(format_string('Attempt to create an instance of field @field_id without a bundle.', array('@field_id' => $this->field_config->id))); + throw new FieldException(format_string('Attempt to create an instance of field @field_id without a bundle.', array('@field_id' => $this->fieldConfig->id))); } // 'Label' defaults to the field ID (mostly useful for field instances // created in tests). $values += array( - 'label' => $this->field_config->id, + 'label' => $this->fieldConfig->id, ); parent::__construct($values, $entity_type); } @@ -284,7 +284,7 @@ public function __construct(array $values, $entity_type = 'field_instance_config * {@inheritdoc} */ public function id() { - return $this->entity_type . '.' . $this->bundle . '.' . $this->field_config->id; + return $this->entity_type . '.' . $this->bundle . '.' . $this->fieldConfig->id; } /** @@ -313,7 +313,7 @@ public function getExportProperties() { // Additionally, include the field type, that is needed to be able to // generate the field-type-dependant parts of the config schema. - $properties['field_type'] = $this->field_config->type; + $properties['field_type'] = $this->fieldConfig->type; return $properties; } @@ -356,8 +356,8 @@ protected function saveNew() { $instance_controller = \Drupal::entityManager()->getStorageController($this->entityType); // Check that the field can be attached to this entity type. - if (!empty($this->field_config->entity_types) && !in_array($this->entity_type, $this->field_config->entity_types)) { - throw new FieldException(format_string('Attempt to create an instance of field @field_id on forbidden entity type @entity_type.', array('@field_id' => $this->field_config->id, '@entity_type' => $this->entity_type))); + if (!empty($this->fieldConfig->entity_types) && !in_array($this->entity_type, $this->fieldConfig->entity_types)) { + throw new FieldException(format_string('Attempt to create an instance of field @field_id on forbidden entity type @entity_type.', array('@field_id' => $this->fieldConfig->id, '@entity_type' => $this->entity_type))); } // Assign the ID. @@ -365,7 +365,7 @@ protected function saveNew() { // Ensure the field instance is unique within the bundle. if ($prior_instance = $instance_controller->load($this->id)) { - throw new FieldException(format_string('Attempt to create an instance of field @field_id on bundle @bundle that already has an instance of that field.', array('@field_id' => $this->field_config->id, '@bundle' => $this->bundle))); + throw new FieldException(format_string('Attempt to create an instance of field @field_id on bundle @bundle that already has an instance of that field.', array('@field_id' => $this->fieldConfig->id, '@bundle' => $this->bundle))); } // Set the field UUID. @@ -425,7 +425,7 @@ protected function saveUpdated() { * Prepares the instance definition for saving. */ protected function prepareSave() { - $field_type_info = field_info_field_types($this->field_config->type); + $field_type_info = field_info_field_types($this->fieldConfig->type); // Set the default instance settings. $this->settings += $field_type_info['instance_settings']; @@ -460,11 +460,11 @@ public function delete($field_cleanup = TRUE) { // Mark instance data for deletion by invoking // hook_field_storage_delete_instance(). - $module_handler->invoke($this->field_config->storage['module'], 'field_storage_delete_instance', array($this)); + $module_handler->invoke($this->fieldConfig->storage['module'], 'field_storage_delete_instance', array($this)); // Remove the instance from the entity form displays. if ($form_display = entity_load('entity_form_display', $this->entity_type . '.' . $this->bundle . '.default')) { - $form_display->removeComponent($this->field_config->id())->save(); + $form_display->removeComponent($this->fieldConfig->id())->save(); } // Remove the instance from the entity displays. @@ -474,12 +474,12 @@ public function delete($field_cleanup = TRUE) { $ids[] = $this->entity_type . '.' . $this->bundle . '.' . $view_mode; } foreach (entity_load_multiple('entity_display', $ids) as $display) { - $display->removeComponent($this->field_config->id())->save(); + $display->removeComponent($this->fieldConfig->id())->save(); } // Delete the field itself if we just deleted its last instance. - if ($field_cleanup && count($this->field_config->getBundles()) == 0) { - $this->field_config->delete(); + if ($field_cleanup && count($this->fieldConfig->getBundles()) == 0) { + $this->fieldConfig->delete(); } } } @@ -487,29 +487,29 @@ public function delete($field_cleanup = TRUE) { /** * {@inheritdoc} */ - public function getField() { - return $this->field_config; + public function getFieldConfig() { + return $this->fieldConfig; } /** * {@inheritdoc} */ public function getFieldName() { - return $this->field_config->id; + return $this->fieldConfig->id; } /** * {@inheritdoc} */ public function getFieldType() { - return $this->field_config->type; + return $this->fieldConfig->type; } /** * {@inheritdoc} */ public function getFieldSettings() { - return $this->settings + $this->field_config->getFieldSettings(); + return $this->settings + $this->fieldConfig->getFieldSettings(); } /** @@ -520,7 +520,7 @@ public function getFieldSetting($setting_name) { return $this->settings[$setting_name]; } else { - return $this->field_config->getFieldSetting($setting_name); + return $this->fieldConfig->getFieldSetting($setting_name); } } @@ -528,7 +528,7 @@ public function getFieldSetting($setting_name) { * {@inheritdoc} */ public function getFieldPropertyNames() { - $schema = $this->field_config->getSchema(); + $schema = $this->fieldConfig->getSchema(); return array_keys($schema['columns']); } @@ -536,7 +536,7 @@ public function getFieldPropertyNames() { * {@inheritdoc} */ public function isFieldTranslatable() { - return $this->field_config->translatable; + return $this->fieldConfig->translatable; } /** @@ -557,7 +557,7 @@ public function getFieldDescription() { * {@inheritdoc} */ public function getFieldCardinality() { - return $this->field_config->cardinality; + return $this->fieldConfig->cardinality; } /** @@ -589,7 +589,7 @@ public function &offsetGet($offset) { return $this->field_uuid; } if ($offset == 'field_name') { - return $this->field_config->id; + return $this->fieldConfig->id; } return $this->{$offset}; } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php index e7775ad..6542b9c 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php @@ -196,7 +196,7 @@ function testImageFieldSettings() { $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size), ); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published')); - $schema = $instance->getField()->getSchema(); + $schema = $instance->getFieldConfig()->getSchema(); $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array( '%max' => $schema['columns']['alt']['length'], '%length' => $test_size, diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php index f59585b..83dd691 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php @@ -67,6 +67,8 @@ function setUp() { * A list of instance settings that will be added to the instance defaults. * @param $widget_settings * A list of widget settings that will be added to the widget defaults. + * + * @return \Drupal\field\Plugin\Core\Entity\FieldInstanceConfig */ function createImageField($name, $type_name, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) { $field = array( @@ -103,7 +105,6 @@ function createImageField($name, $type_name, $field_settings = array(), $instanc ->save(); return $field_instance_config; - } /**