From cdac25ee084a546e9b37f082e02662cded76dee2 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 9 Dec 2013 19:19:58 -0400 Subject: [PATCH] Issue #2143263 by plopesc | yched: Remove "Field" prefix from FieldDefinitionInterface methods. --- .../Drupal/Core/Entity/ContentEntityBase.php | 9 +- core/lib/Drupal/Core/Entity/EntityManager.php | 6 +- .../FieldableDatabaseStorageController.php | 21 ++--- .../FieldableEntityStorageControllerBase.php | 2 +- .../Drupal/Core/Entity/Query/Sql/Tables.php | 8 +- .../Drupal/Core/Field/ConfigFieldItemList.php | 8 +- .../lib/Drupal/Core/Field/FieldDefinition.php | 82 ++++-------------- .../Core/Field/FieldDefinitionInterface.php | 28 +++---- core/lib/Drupal/Core/Field/FieldItemBase.php | 4 +- core/lib/Drupal/Core/Field/FieldItemList.php | 2 +- core/lib/Drupal/Core/Field/FormatterBase.php | 12 +-- .../Core/Field/FormatterPluginManager.php | 2 +- .../Field/FieldType/LegacyConfigFieldItem.php | 2 +- .../FieldType/LegacyConfigFieldItemList.php | 6 +- core/lib/Drupal/Core/Field/WidgetBase.php | 34 ++++---- .../Drupal/Core/Field/WidgetPluginManager.php | 2 +- .../lib/Drupal/aggregator/Entity/Item.php | 2 +- .../Tests/CustomBlockFieldTest.php | 10 +-- .../Tests/CustomBlockTypeTest.php | 2 +- core/modules/comment/comment.module | 36 ++++---- .../Drupal/comment/CommentFormController.php | 6 +- .../lib/Drupal/comment/CommentViewBuilder.php | 2 +- .../lib/Drupal/comment/Entity/Comment.php | 8 +- .../CommentDefaultFormatter.php | 2 +- .../Plugin/Field/FieldType/CommentItem.php | 4 +- .../Field/FieldWidget/CommentWidget.php | 4 +- .../comment/Tests/CommentNonNodeTest.php | 4 +- .../lib/Drupal/contact/Entity/Message.php | 4 +- .../content_translation.admin.inc | 12 +-- .../content_translation.module | 10 +-- .../content_translation.pages.inc | 2 +- .../FieldTranslationSynchronizer.php | 4 +- .../Tests/ContentTranslationSettingsTest.php | 10 +-- core/modules/datetime/datetime.module | 4 +- .../lib/Drupal/datetime/DateTimeComputed.php | 2 +- .../datetime/Tests/DateTimeItemTest.php | 2 +- .../lib/Drupal/edit/Form/EditFieldForm.php | 2 +- .../lib/Drupal/edit/MetadataGenerator.php | 4 +- .../Plugin/InPlaceEditor/PlainTextEditor.php | 4 +- .../Plugin/InPlaceEditor/WysiwygEditor.php | 4 +- core/modules/editor/editor.module | 4 +- .../editor/Plugin/InPlaceEditor/Editor.php | 4 +- .../Drupal/email/ConfigurableEmailItem.php | 2 +- .../lib/Drupal/entity/EntityDisplayBase.php | 3 +- .../entity_reference/entity_reference.module | 6 +- .../ConfigurableEntityReferenceItem.php | 4 +- .../EntityReferenceAutocomplete.php | 2 +- .../EntityReferenceController.php | 2 +- ...nfigurableEntityReferenceFieldItemList.php | 4 +- .../FieldWidget/AutocompleteWidgetBase.php | 2 +- .../Plugin/Type/SelectionPluginManager.php | 4 +- .../selection/SelectionBase.php | 18 ++-- core/modules/field/field.api.php | 2 +- core/modules/field/field.attach.inc | 6 +- core/modules/field/field.deprecated.inc | 14 ++-- core/modules/field/field.module | 4 +- core/modules/field/field.multilingual.inc | 4 +- core/modules/field/field.purge.inc | 2 +- core/modules/field/field.views.inc | 12 +-- .../field/lib/Drupal/field/Entity/Field.php | 83 +++++-------------- .../lib/Drupal/field/Entity/FieldInstance.php | 72 ++++------------ .../field/lib/Drupal/field/FieldInfo.php | 16 ++-- .../Drupal/field/Plugin/views/field/Field.php | 14 ++-- .../lib/Drupal/field/Tests/BulkDeleteTest.php | 2 +- .../field/lib/Drupal/field/Tests/CrudTest.php | 10 +-- .../field/Tests/FieldAttachOtherTest.php | 58 ++++++------- .../field/Tests/FieldAttachStorageTest.php | 8 +- .../field/Tests/FieldImportChangeTest.php | 2 +- .../lib/Drupal/field/Tests/FieldInfoTest.php | 12 +-- .../field/Tests/FieldInstanceCrudTest.php | 12 +-- .../field/Tests/FieldValidationTest.php | 6 +- .../field/lib/Drupal/field/Tests/FormTest.php | 4 +- .../Drupal/field/Tests/TranslationTest.php | 6 +- .../Drupal/field/Tests/TranslationWebTest.php | 4 +- .../field/Tests/Views/FieldTestBase.php | 2 +- .../Tests/Views/HandlerFieldFieldTest.php | 21 +++-- .../modules/field_test/field_test.field.inc | 6 +- .../modules/field_test/field_test.module | 2 +- .../Plugin/Field/FieldType/ShapeItem.php | 8 +- .../Plugin/Field/FieldType/TestItem.php | 2 +- .../lib/Drupal/field_ui/DisplayOverview.php | 4 +- .../Drupal/field_ui/DisplayOverviewBase.php | 6 +- .../lib/Drupal/field_ui/FieldOverview.php | 18 ++-- .../Drupal/field_ui/Form/FieldDeleteForm.php | 2 +- .../Drupal/field_ui/Form/FieldEditForm.php | 8 +- .../field_ui/Form/FieldInstanceEditForm.php | 20 ++--- .../Drupal/field_ui/FormDisplayOverview.php | 2 +- .../field_ui/Tests/ManageFieldsTest.php | 4 +- core/modules/file/file.field.inc | 2 +- core/modules/file/file.module | 4 +- core/modules/file/file.views.inc | 6 +- .../file/lib/Drupal/file/Entity/File.php | 2 +- .../Field/FieldType/FileFieldItemList.php | 2 +- .../Plugin/Field/FieldWidget/FileWidget.php | 10 +-- .../Drupal/file/Tests/FileFieldTestBase.php | 2 +- .../file/Tests/FileFieldValidateTest.php | 4 +- .../file_module_test/file_module_test.module | 2 +- .../EntityReferenceItemNormalizer.php | 2 +- .../hal/Normalizer/FieldItemNormalizer.php | 2 +- .../Drupal/hal/Normalizer/FieldNormalizer.php | 2 +- core/modules/image/image.views.inc | 6 +- .../lib/Drupal/image/Entity/ImageStyle.php | 4 +- .../FieldFormatter/ImageFormatterBase.php | 2 +- .../Plugin/Field/FieldType/ImageItem.php | 2 +- .../Plugin/Field/FieldWidget/ImageWidget.php | 4 +- .../Tests/ImageFieldDefaultImagesTest.php | 12 +-- .../image/Tests/ImageFieldDisplayTest.php | 6 +- .../Plugin/Field/FieldWidget/LinkWidget.php | 2 +- .../node/lib/Drupal/node/Entity/Node.php | 12 +-- .../lib/Drupal/node/NodeTitleItemList.php | 4 +- .../lib/Drupal/node/Tests/NodeTypeTest.php | 2 +- core/modules/node/node.tokens.inc | 2 +- .../Plugin/Field/FieldType/NumberItemBase.php | 2 +- .../Plugin/Field/FieldWidget/NumberWidget.php | 2 +- .../Plugin/Field/FieldWidget/OnOffWidget.php | 2 +- .../Field/FieldWidget/OptionsWidgetBase.php | 4 +- .../options/Tests/OptionsFieldUITest.php | 10 +-- .../options/Tests/OptionsWidgetsTest.php | 22 ++--- core/modules/options/options.install | 2 +- core/modules/options/options.module | 26 +++--- .../Drupal/path/Tests/PathLanguageTest.php | 2 +- core/modules/system/entity.api.php | 4 +- .../system/Tests/Entity/EntityFieldTest.php | 16 ++-- .../Tests/Entity/EntityLanguageTestBase.php | 4 +- .../Entity/EntityTranslationFormTest.php | 2 +- .../Tests/Entity/EntityTranslationTest.php | 6 +- .../modules/entity_test/entity_test.module | 6 +- .../Drupal/entity_test/Entity/EntityTest.php | 2 +- .../Controller/TermAutocompleteController.php | 4 +- .../lib/Drupal/taxonomy/Entity/Term.php | 6 +- .../lib/Drupal/taxonomy/Entity/Vocabulary.php | 2 +- .../TaxonomyAutocompleteWidget.php | 2 +- .../selection/TermSelection.php | 2 +- .../Tests/TermFieldMultipleVocabularyTest.php | 2 +- .../Drupal/taxonomy/Tests/TermFieldTest.php | 2 +- .../lib/Drupal/taxonomy/Tests/TermTest.php | 12 +-- core/modules/taxonomy/taxonomy.module | 14 ++-- core/modules/taxonomy/taxonomy.views.inc | 6 +- .../Plugin/Field/FieldType/TelephoneItem.php | 2 +- .../text/Plugin/Field/FieldType/TextItem.php | 2 +- .../text/lib/Drupal/text/TextProcessed.php | 2 +- .../user/lib/Drupal/user/Entity/User.php | 12 +-- .../selection/UserSelection.php | 2 +- .../selection/ViewsSelection.php | 12 +-- core/modules/views_ui/admin.inc | 2 +- .../Tests/Core/Entity/FieldDefinitionTest.php | 44 +++++----- 146 files changed, 548 insertions(+), 677 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 38a03d47e1a7..b9942490a03b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -401,8 +401,9 @@ protected function getTranslatedField($name, $langcode) { } // Non-translatable fields are always stored with // Language::LANGCODE_DEFAULT as key. + $default = $langcode == Language::LANGCODE_DEFAULT; - if (!$default && !$definition->isFieldTranslatable()) { + if (!$default && !$definition->isTranslatable()) { if (!isset($this->fields[$name][Language::LANGCODE_DEFAULT])) { $this->fields[$name][Language::LANGCODE_DEFAULT] = $this->getTranslatedField($name, Language::LANGCODE_DEFAULT); } @@ -728,7 +729,7 @@ public function addTranslation($langcode, array $values = array()) { $definitions = $translation->getPropertyDefinitions(); foreach ($values as $name => $value) { - if (isset($definitions[$name]) && $definitions[$name]->isFieldTranslatable()) { + if (isset($definitions[$name]) && $definitions[$name]->isTranslatable()) { $translation->$name = $value; } } @@ -742,7 +743,7 @@ public function addTranslation($langcode, array $values = array()) { public function removeTranslation($langcode) { if (isset($this->translations[$langcode]) && $langcode != Language::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { foreach ($this->getPropertyDefinitions() as $name => $definition) { - if ($definition->isFieldTranslatable()) { + if ($definition->isTranslatable()) { unset($this->values[$name][$langcode]); unset($this->fields[$name][$langcode]); } @@ -928,7 +929,7 @@ public function __clone() { // object keyed by language. To avoid creating different field objects // we retain just the original value, as references will be recreated // later as needed. - if (!$definitions[$name]->isFieldTranslatable() && count($values) > 1) { + if (!$definitions[$name]->isTranslatable() && count($values) > 1) { $values = array_intersect_key($values, array(Language::LANGCODE_DEFAULT => TRUE)); } foreach ($values as $langcode => $items) { diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index ed359f6140a4..83a671c84309 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -357,7 +357,7 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { foreach (array('definitions', 'optional') as $key) { foreach ($this->entityFieldInfo[$entity_type][$key] as $field_name => &$definition) { if ($definition instanceof FieldDefinition) { - $definition->setFieldName($field_name); + $definition->setName($field_name); } } } @@ -372,8 +372,8 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { $untranslatable_fields = array_flip(array('langcode') + $keys); foreach (array('definitions', 'optional') as $key) { foreach ($this->entityFieldInfo[$entity_type][$key] as $field_name => &$definition) { - if (isset($untranslatable_fields[$field_name]) && $definition->isFieldTranslatable()) { - throw new \LogicException(format_string('The @field field cannot be translatable.', array('@field' => $definition->getFieldLabel()))); + if (isset($untranslatable_fields[$field_name]) && $definition->isTranslatable()) { + throw new \LogicException(format_string('The @field field cannot be translatable.', array('@field' => $definition->getLabel()))); } } } diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php index e921796ac158..d82c8cf56026 100644 --- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php @@ -917,14 +917,15 @@ protected function doLoadFieldItems($entities, $age) { $delta_count = array(); foreach ($results as $row) { + // Ensure that records for non-translatable fields having invalid // languages are skipped. - if ($row->langcode == $default_langcodes[$row->entity_id] || $field->isFieldTranslatable()) { + if ($row->langcode == $default_langcodes[$row->entity_id] || $field->isTranslatable()) { if (!isset($delta_count[$row->entity_id][$row->langcode])) { $delta_count[$row->entity_id][$row->langcode] = 0; } - if ($field->getFieldCardinality() == FieldInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field->getFieldCardinality()) { + if ($field->getCardinality() == FieldInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field->getCardinality()) { $item = array(); // For each column declared by the field, populate the item from the // prefixed database column. @@ -987,7 +988,7 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) { $query = $this->database->insert($table_name)->fields($columns); $revision_query = $this->database->insert($revision_name)->fields($columns); - $langcodes = $field->isFieldTranslatable() ? $translation_langcodes : array($default_langcode); + $langcodes = $field->isTranslatable() ? $translation_langcodes : array($default_langcode); foreach ($langcodes as $langcode) { $delta_count = 0; $items = $entity->getTranslation($langcode)->get($field_name); @@ -1010,7 +1011,7 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) { $query->values($record); $revision_query->values($record); - if ($field->getFieldCardinality() != FieldInterface::CARDINALITY_UNLIMITED && ++$delta_count == $field->getFieldCardinality()) { + if ($field->getCardinality() != FieldInterface::CARDINALITY_UNLIMITED && ++$delta_count == $field->getCardinality()) { break; } } @@ -1279,12 +1280,12 @@ public function onFieldPurge(FieldInterface $field) { */ public static function _fieldSqlSchema(FieldInterface $field, array $schema = NULL) { if ($field->deleted) { - $description_current = "Data storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getFieldName()})."; - $description_revision = "Revision archive storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getFieldName()})."; + $description_current = "Data storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getName()})."; + $description_revision = "Revision archive storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getName()})."; } else { - $description_current = "Data storage for {$field->entity_type} field {$field->getFieldName()}."; - $description_revision = "Revision archive storage for {$field->entity_type} field {$field->getFieldName()}."; + $description_current = "Data storage for {$field->entity_type} field {$field->getName()}."; + $description_revision = "Revision archive storage for {$field->entity_type} field {$field->getName()}."; } $current = array( @@ -1498,7 +1499,7 @@ static protected function _generateFieldTableName(FieldInterface $field, $revisi * unique among all other fields. */ static public function _fieldIndexName(FieldInterface $field, $index) { - return $field->getFieldName() . '_' . $index; + return $field->getName() . '_' . $index; } /** @@ -1521,7 +1522,7 @@ static public function _fieldIndexName(FieldInterface $field, $index) { * unique among all other fields. */ static public function _fieldColumnName(FieldInterface $field, $column) { - return in_array($column, Field::getReservedColumns()) ? $column : $field->getFieldName() . '_' . $column; + return in_array($column, Field::getReservedColumns()) ? $column : $field->getName() . '_' . $column; } } diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php index ec909d9904d6..74b5bf322714 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php @@ -263,7 +263,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->getFieldName(), $entity); + $items = \Drupal::typedData()->create($instance, $values, $instance->getName(), $entity); $items->delete(); } $this->purgeFieldItems($entity, $instance); diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index b02cfd4cf0fc..809884911305 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -136,7 +136,7 @@ public function addField($field, $type, $langcode) { // Get the field definitions form a mocked entity. $values = array(); - $field_name = $field->getFieldName(); + $field_name = $field->getName(); // If there are bundles, pick one. if (!empty($entity_info['entity_keys']['bundle'])) { $values[$entity_info['entity_keys']['bundle']] = reset($field_map[$entity_type][$field_name]['bundles']); @@ -151,7 +151,7 @@ public function addField($field, $type, $langcode) { // column, i.e. target_id or fid. // Otherwise, the code executing the relationship will throw an // exception anyways so no need to do it here. - if (!$column && isset($propertyDefinitions[$relationship_specifier]) && $entity->{$field->getFieldName()}->get('entity') instanceof EntityReference) { + if (!$column && isset($propertyDefinitions[$relationship_specifier]) && $entity->{$field->getName()}->get('entity') instanceof EntityReference) { $column = current(array_keys($propertyDefinitions)); } // Prepare the next index prefix. @@ -249,10 +249,10 @@ protected function ensureEntityTable($index_prefix, $property, $type, $langcode, * @throws \Drupal\Core\Entity\Query\QueryException */ protected function ensureFieldTable($index_prefix, &$field, $type, $langcode, $base_table, $entity_id_field, $field_id_field) { - $field_name = $field->getFieldName(); + $field_name = $field->getName(); if (!isset($this->fieldTables[$index_prefix . $field_name])) { $table = $this->sqlQuery->getMetaData('age') == EntityStorageControllerInterface::FIELD_LOAD_CURRENT ? FieldableDatabaseStorageController::_fieldTableName($field) : FieldableDatabaseStorageController::_fieldRevisionTableName($field); - if ($field->getFieldCardinality() != 1) { + if ($field->getCardinality() != 1) { $this->sqlQuery->addMetaData('simple_query', FALSE); } $entity_type = $this->sqlQuery->getMetaData('entity_type'); diff --git a/core/lib/Drupal/Core/Field/ConfigFieldItemList.php b/core/lib/Drupal/Core/Field/ConfigFieldItemList.php index 738df25975be..0da28d0b6e0d 100644 --- a/core/lib/Drupal/Core/Field/ConfigFieldItemList.php +++ b/core/lib/Drupal/Core/Field/ConfigFieldItemList.php @@ -64,13 +64,13 @@ public function getConstraints() { // Check that the number of values doesn't exceed the field cardinality. For // form submitted values, this can only happen with 'multiple value' // widgets. - $cardinality = $this->getFieldDefinition()->getFieldCardinality(); + $cardinality = $this->getFieldDefinition()->getCardinality(); if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) { $constraints[] = \Drupal::typedData() ->getValidationConstraintManager() ->create('Count', array( 'max' => $cardinality, - 'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@count' => $cardinality)), + 'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality)), )); } @@ -102,7 +102,7 @@ public function defaultValuesFormValidate(array $element, array &$form, array &$ if (count($violations)) { // Store reported errors in $form_state. - $field_name = $this->getFieldDefinition()->getFieldName(); + $field_name = $this->getFieldDefinition()->getName(); $field_state = field_form_get_state($element['#parents'], $field_name, $form_state); $field_state['constraint_violations'] = $violations; field_form_set_state($element['#parents'], $field_name, $form_state, $field_state); @@ -142,7 +142,7 @@ protected function defaultValueWidget(array &$form_state) { // Use the widget currently configured for the 'default' form mode, or // fallback to the default widget for the field type. $entity_form_display = entity_get_form_display($entity->entityType(), $entity->bundle(), 'default'); - $widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getFieldName()); + $widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName()); if (!$widget) { $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition())); } diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php index a5ab05a34d7a..0829820b1843 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinition.php +++ b/core/lib/Drupal/Core/Field/FieldDefinition.php @@ -32,7 +32,7 @@ public static function create($type) { /** * {@inheritdoc} */ - public function getFieldName() { + public function getName() { return $this->definition['field_name']; } @@ -45,7 +45,7 @@ public function getFieldName() { * @return static * The object itself for chaining. */ - public function setFieldName($name) { + public function setName($name) { $this->definition['field_name'] = $name; return $this; } @@ -53,7 +53,7 @@ public function setFieldName($name) { /** * {@inheritdoc} */ - public function getFieldType() { + public function getType() { $data_type = $this->getItemDefinition()->getDataType(); // Cut of the leading field_item: prefix from 'field_item:FIELD_TYPE'. $parts = explode(':', $data_type); @@ -63,7 +63,7 @@ public function getFieldType() { /** * {@inheritdoc} */ - public function getFieldSettings() { + public function getSettings() { return $this->getItemDefinition()->getSettings(); } @@ -76,7 +76,7 @@ public function getFieldSettings() { * @return static * The object itself for chaining. */ - public function setFieldSettings(array $settings) { + public function setSettings(array $settings) { $this->getItemDefinition()->setSettings($settings); return $this; } @@ -84,7 +84,7 @@ public function setFieldSettings(array $settings) { /** * {@inheritdoc} */ - public function getFieldSetting($setting_name) { + public function getSetting($setting_name) { return $this->getItemDefinition()->getSetting($setting_name); } @@ -99,7 +99,7 @@ public function getFieldSetting($setting_name) { * @return static * The object itself for chaining. */ - public function setFieldSetting($setting_name, $value) { + public function setSetting($setting_name, $value) { $this->getItemDefinition()->setSetting($setting_name, $value); return $this; } @@ -107,14 +107,14 @@ public function setFieldSetting($setting_name, $value) { /** * {@inheritdoc} */ - public function getFieldPropertyNames() { + public function getPropertyNames() { return array_keys(\Drupal::typedData()->create($this->getItemDefinition())->getPropertyDefinitions()); } /** * {@inheritdoc} */ - public function isFieldTranslatable() { + public function isTranslatable() { return !empty($this->definition['translatable']); } @@ -135,35 +135,7 @@ public function setTranslatable($translatable) { /** * {@inheritdoc} */ - public function getFieldLabel() { - return $this->getLabel(); - } - - /** - * {@inheritdoc} - */ - public function setFieldLabel($label) { - return $this->setLabel($label); - } - - /** - * {@inheritdoc} - */ - public function getFieldDescription() { - return $this->getDescription(); - } - - /** - * {@inheritdoc} - */ - public function setFieldDescription($description) { - return $this->setDescription($description); - } - - /** - * {@inheritdoc} - */ - public function getFieldCardinality() { + public function getCardinality() { // @todo: Allow to control this. return isset($this->definition['cardinality']) ? $this->definition['cardinality'] : 1; } @@ -171,35 +143,15 @@ public function getFieldCardinality() { /** * {@inheritdoc} */ - public function isFieldRequired() { - return $this->isRequired(); - } - - /** - * {@inheritdoc} - */ - public function isFieldMultiple() { - $cardinality = $this->getFieldCardinality(); + public function isMultiple() { + $cardinality = $this->getCardinality(); return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1); } - /** - * Sets whether the field is required. - * - * @param bool $required - * Whether the field is required. - * - * @return static - * The object itself for chaining. - */ - public function setFieldRequired($required) { - return $this->setRequired($required); - } - /** * {@inheritdoc} */ - public function isFieldQueryable() { + public function isQueryable() { return isset($this->definition['queryable']) ? $this->definition['queryable'] : !$this->isComputed(); } @@ -212,7 +164,7 @@ public function isFieldQueryable() { * @return static * The object itself for chaining. */ - public function setFieldQueryable($queryable) { + public function setQueryable($queryable) { $this->definition['queryable'] = $queryable; return $this; } @@ -238,15 +190,15 @@ public function setPropertyConstraints($name, array $constraints) { /** * {@inheritdoc} */ - public function isFieldConfigurable() { + public function isConfigurable() { return FALSE; } /** * {@inheritdoc} */ - public function getFieldDefaultValue(EntityInterface $entity) { - return $this->getFieldSetting('default_value'); + public function getDefaultValue(EntityInterface $entity) { + return $this->getSetting('default_value'); } } diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php index 4dca17af3117..76f0ef90451f 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php @@ -67,7 +67,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface { * @return string * The field name. */ - public function getFieldName(); + public function getName(); /** * Returns the field type. @@ -77,7 +77,7 @@ public function getFieldName(); * * @see \Drupal\Core\Field\FieldTypePluginManager */ - public function getFieldType(); + public function getType(); /** * Returns the field settings. @@ -89,7 +89,7 @@ public function getFieldType(); * @return array * An array of key/value pairs. */ - public function getFieldSettings(); + public function getSettings(); /** * Returns the value of a given field setting. @@ -100,7 +100,7 @@ public function getFieldSettings(); * @return mixed * The setting value. */ - public function getFieldSetting($setting_name); + public function getSetting($setting_name); /** * Returns the names of the field's subproperties. @@ -116,7 +116,7 @@ public function getFieldSetting($setting_name); * @return array * The property names. */ - public function getFieldPropertyNames(); + public function getPropertyNames(); /** * Returns whether the field is translatable. @@ -124,7 +124,7 @@ public function getFieldPropertyNames(); * @return bool * TRUE if the field is translatable. */ - public function isFieldTranslatable(); + public function isTranslatable(); /** * Determines whether the field is configurable via field.module. @@ -132,7 +132,7 @@ public function isFieldTranslatable(); * @return bool * TRUE if the field is configurable. */ - public function isFieldConfigurable(); + public function isConfigurable(); /** * Determines whether the field is queryable via QueryInterface. @@ -140,7 +140,7 @@ public function isFieldConfigurable(); * @return bool * TRUE if the field is queryable. */ - public function isFieldQueryable(); + public function isQueryable(); /** * Returns the human-readable label for the field. @@ -148,7 +148,7 @@ public function isFieldQueryable(); * @return string * The field label. */ - public function getFieldLabel(); + public function getLabel(); /** * Returns the human-readable description for the field. @@ -160,7 +160,7 @@ public function getFieldLabel(); * @return string|null * The field description, or NULL if no description is available. */ - public function getFieldDescription(); + public function getDescription(); /** * Returns the maximum number of items allowed for the field. @@ -171,7 +171,7 @@ public function getFieldDescription(); * @return integer * The field cardinality. */ - public function getFieldCardinality(); + public function getCardinality(); /** * Returns whether at least one non-empty item is required for this field. @@ -182,7 +182,7 @@ public function getFieldCardinality(); * @return bool * TRUE if the field is required. */ - public function isFieldRequired(); + public function isRequired(); /** * Returns whether the field can contain multiple items. @@ -190,7 +190,7 @@ public function isFieldRequired(); * @return bool * TRUE if the field can contain multiple items, FALSE otherwise. */ - public function isFieldMultiple(); + public function isMultiple(); /** * Returns the default value for the field in a newly created entity. @@ -207,6 +207,6 @@ public function isFieldMultiple(); * array. * - NULL or array() for no default value. */ - public function getFieldDefaultValue(EntityInterface $entity); + public function getDefaultValue(EntityInterface $entity); } diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 28a659779557..147de5f359ae 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -65,7 +65,7 @@ public function getFieldDefinition() { * The array of settings. */ protected function getFieldSettings() { - return $this->getFieldDefinition()->getFieldSettings(); + return $this->getFieldDefinition()->getSettings(); } /** @@ -78,7 +78,7 @@ protected function getFieldSettings() { * The setting value. */ protected function getFieldSetting($setting_name) { - return $this->getFieldDefinition()->getFieldSetting($setting_name); + return $this->getFieldDefinition()->getSetting($setting_name); } /** diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 51bdc49ad291..1af325402b3d 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -230,7 +230,7 @@ public function applyDefaultValue($notify = TRUE) { * The default value for the field. */ protected function getDefaultValue() { - return $this->getFieldDefinition()->getFieldDefaultValue($this->getEntity()); + return $this->getFieldDefinition()->getDefaultValue($this->getEntity()); } /** diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php index fc4f2a99cb0e..1a121e718567 100644 --- a/core/lib/Drupal/Core/Field/FormatterBase.php +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -75,17 +75,17 @@ public function view(FieldItemListInterface $items) { if ($elements) { $entity = $items->getEntity(); $entity_type = $entity->entityType(); - $field_name = $this->fieldDefinition->getFieldName(); + $field_name = $this->fieldDefinition->getName(); $info = array( '#theme' => 'field', - '#title' => $this->fieldDefinition->getFieldLabel(), + '#title' => $this->fieldDefinition->getLabel(), '#access' => $items->access('view'), '#label_display' => $this->label, '#view_mode' => $this->viewMode, '#language' => $items->getLangcode(), '#field_name' => $field_name, - '#field_type' => $this->fieldDefinition->getFieldType(), - '#field_translatable' => $this->fieldDefinition->isFieldTranslatable(), + '#field_type' => $this->fieldDefinition->getType(), + '#field_translatable' => $this->fieldDefinition->isTranslatable(), '#entity_type' => $entity_type, '#bundle' => $entity->bundle(), '#object' => $entity, @@ -138,7 +138,7 @@ public function prepareView(array $entities_items) { } * The array of settings. */ protected function getFieldSettings() { - return $this->fieldDefinition->getFieldSettings(); + return $this->fieldDefinition->getSettings(); } /** @@ -151,7 +151,7 @@ protected function getFieldSettings() { * The setting value. */ protected function getFieldSetting($setting_name) { - return $this->fieldDefinition->getFieldSetting($setting_name); + return $this->fieldDefinition->getSetting($setting_name); } } diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index 4a7b16b2aa67..18a7789c57e5 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -101,7 +101,7 @@ public function createInstance($plugin_id, array $configuration) { public function getInstance(array $options) { $configuration = $options['configuration']; $field_definition = $options['field_definition']; - $field_type = $field_definition->getFieldType(); + $field_type = $field_definition->getType(); // Fill in default configuration if needed. if (!isset($options['prepare']) || $options['prepare'] == TRUE) { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php index 336f0f87f77e..8c24ca9c6b71 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php @@ -51,7 +51,7 @@ public function isEmpty() { $item = $this->getValue(TRUE); // The previous hook was never called on an empty item, but // ContentEntityBase always creates a FieldItem element for an empty field. - return empty($item) || $callback($item, $this->getFieldDefinition()->getFieldType()); + return empty($item) || $callback($item, $this->getFieldDefinition()->getType()); } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItemList.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItemList.php index f239c60a0292..2351d6c65bf7 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItemList.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItemList.php @@ -40,14 +40,14 @@ public function validate() { $this->legacyCallback('validate', array(&$legacy_errors)); $langcode = $this->getLangcode(); - $field_name = $this->getFieldDefinition()->getFieldName(); + $field_name = $this->getFieldDefinition()->getName(); if (isset($legacy_errors[$field_name][$langcode])) { foreach ($legacy_errors[$field_name][$langcode] as $delta => $item_errors) { foreach ($item_errors as $item_error) { // We do not have the information about which column triggered the // error, so assume the first column... - $property_names = $this->getFieldDefinition()->getFieldPropertyNames(); + $property_names = $this->getFieldDefinition()->getPropertyNames(); $property_name = $property_names[0]; $violations->add(new ConstraintViolation($item_error['message'], $item_error['message'], array(), $this, $delta . '.' . $property_name, $this->offsetGet($delta)->get($property_name)->getValue(), NULL, $item_error['error'])); } @@ -102,7 +102,7 @@ public function deleteRevision() { * The name of the hook, e.g. 'presave', 'validate'. */ protected function legacyCallback($hook, $args = array()) { - $type_definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getFieldDefinition()->getFieldType()); + $type_definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getFieldDefinition()->getType()); $module = $type_definition['provider']; $callback = "{$module}_field_{$hook}"; if (function_exists($callback)) { diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 879f8e74fc27..075e14265eda 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -51,7 +51,7 @@ public function __construct($plugin_id, array $plugin_definition, FieldDefinitio * {@inheritdoc} */ public function form(FieldItemListInterface $items, array &$form, array &$form_state, $get_delta = NULL) { - $field_name = $this->fieldDefinition->getFieldName(); + $field_name = $this->fieldDefinition->getName(); $parents = $form['#parents']; // Store field information in $form_state. @@ -74,8 +74,8 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s if (isset($get_delta) || $definition['multiple_values']) { $delta = isset($get_delta) ? $get_delta : 0; $element = array( - '#title' => check_plain($this->fieldDefinition->getFieldLabel()), - '#description' => field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getFieldDescription())), + '#title' => check_plain($this->fieldDefinition->getLabel()), + '#description' => field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription())), ); $element = $this->formSingleElement($items, $delta, $element, $form, $form_state); @@ -118,7 +118,7 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s '#parents' => array_merge($parents, array($field_name . '_wrapper')), '#attributes' => array( 'class' => array( - 'field-type-' . drupal_html_class($this->fieldDefinition->getFieldType()), + 'field-type-' . drupal_html_class($this->fieldDefinition->getType()), 'field-name-' . drupal_html_class($field_name), 'field-widget-' . drupal_html_class($this->getPluginId()), ), @@ -140,8 +140,8 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s * - table display and drag-n-drop value reordering */ protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) { - $field_name = $this->fieldDefinition->getFieldName(); - $cardinality = $this->fieldDefinition->getFieldCardinality(); + $field_name = $this->fieldDefinition->getName(); + $cardinality = $this->fieldDefinition->getCardinality(); $parents = $form['#parents']; // Determine the number of widgets to display. @@ -161,8 +161,8 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f $id_prefix = implode('-', array_merge($parents, array($field_name))); $wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper'); - $title = check_plain($this->fieldDefinition->getFieldLabel()); - $description = field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getFieldDescription())); + $title = check_plain($this->fieldDefinition->getLabel()); + $description = field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription())); $elements = array(); @@ -200,8 +200,8 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f '#theme' => 'field_multiple_value_form', '#field_name' => $field_name, '#cardinality' => $cardinality, - '#cardinality_multiple' => $this->fieldDefinition->isFieldMultiple(), - '#required' => $this->fieldDefinition->isFieldRequired(), + '#cardinality_multiple' => $this->fieldDefinition->isMultiple(), + '#required' => $this->fieldDefinition->isRequired(), '#title' => $title, '#description' => $description, '#prefix' => '<div id="' . $wrapper_id . '">', @@ -240,11 +240,11 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra '#entity_type' => $entity->entityType(), '#bundle' => $entity->bundle(), '#entity' => $entity, - '#field_name' => $this->fieldDefinition->getFieldName(), + '#field_name' => $this->fieldDefinition->getName(), '#language' => $items->getLangcode(), '#field_parents' => $form['#parents'], // Only the first widget should be required. - '#required' => $delta == 0 && $this->fieldDefinition->isFieldRequired(), + '#required' => $delta == 0 && $this->fieldDefinition->isRequired(), '#delta' => $delta, '#weight' => $delta, ); @@ -270,7 +270,7 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra * {@inheritdoc} */ public function extractFormValues(FieldItemListInterface $items, array $form, array &$form_state) { - $field_name = $this->fieldDefinition->getFieldName(); + $field_name = $this->fieldDefinition->getName(); // Extract the values from $form_state['values']. $path = array_merge($form['#parents'], array($field_name)); @@ -323,7 +323,7 @@ public function extractFormValues(FieldItemListInterface $items, array $form, ar * {@inheritdoc} */ public function flagErrors(FieldItemListInterface $items, array $form, array &$form_state) { - $field_name = $this->fieldDefinition->getFieldName(); + $field_name = $this->fieldDefinition->getName(); $field_state = field_form_get_state($form['#parents'], $field_name, $form_state); @@ -426,7 +426,7 @@ public function massageFormValues(array $values, array $form, array &$form_state * The field values. */ protected function sortItems(FieldItemListInterface $items) { - if ($this->fieldDefinition->isFieldMultiple() && isset($items[0]->_weight)) { + if ($this->fieldDefinition->isMultiple() && isset($items[0]->_weight)) { $itemValues = $items->getValue(TRUE); usort($itemValues, function ($a, $b) { $a_weight = (is_array($a) ? $a['_weight'] : 0); @@ -448,7 +448,7 @@ protected function sortItems(FieldItemListInterface $items) { * The array of settings. */ protected function getFieldSettings() { - return $this->fieldDefinition->getFieldSettings(); + return $this->fieldDefinition->getSettings(); } /** @@ -461,7 +461,7 @@ protected function getFieldSettings() { * The setting value. */ protected function getFieldSetting($setting_name) { - return $this->fieldDefinition->getFieldSetting($setting_name); + return $this->fieldDefinition->getSetting($setting_name); } } diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index d6700737a7ea..0a789866e351 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -87,7 +87,7 @@ public function getInstance(array $options) { $configuration = $options['configuration']; $field_definition = $options['field_definition']; - $field_type = $field_definition->getFieldType(); + $field_type = $field_definition->getType(); // Fill in default configuration if needed. if ($options['prepare']) { diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php index 4a16a1289dfe..12829368f7db 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php @@ -71,7 +71,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['fid'] = FieldDefinition::create('entity_reference') ->setLabel(t('Aggregator feed ID')) ->setDescription(t('The ID of the aggregator feed.')) - ->setFieldSetting('target_type', 'aggregator_feed'); + ->setSetting('target_type', 'aggregator_feed'); $fields['title'] = FieldDefinition::create('string') ->setLabel(t('Title')) diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php index 54b5d6f7524b..57f1e99021c7 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php @@ -72,7 +72,7 @@ public function testBlockFields() { )); $this->field->save(); $this->instance = entity_create('field_instance', array( - 'field_name' => $this->field->getFieldName(), + 'field_name' => $this->field->getName(), 'entity_type' => 'custom_block', 'bundle' => 'link', 'settings' => array( @@ -81,12 +81,12 @@ public function testBlockFields() { )); $this->instance->save(); entity_get_form_display('custom_block', 'link', 'default') - ->setComponent($this->field->getFieldName(), array( + ->setComponent($this->field->getName(), array( 'type' => 'link_default', )) ->save(); entity_get_display('custom_block', 'link', 'default') - ->setComponent($this->field->getFieldName(), array( + ->setComponent($this->field->getName(), array( 'type' => 'link', 'label' => 'hidden', )) @@ -96,8 +96,8 @@ public function testBlockFields() { $this->drupalGet('block/add/link'); $edit = array( 'info' => $this->randomName(8), - $this->field->getFieldName() . '[0][url]' => 'http://example.com', - $this->field->getFieldName() . '[0][title]' => 'Example.com' + $this->field->getName() . '[0][url]' => 'http://example.com', + $this->field->getName() . '[0][title]' => 'Example.com' ); $this->drupalPostForm(NULL, $edit, t('Save')); $block = entity_load('custom_block', 1); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index ab67e9b2df8c..7593adb461b8 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -79,7 +79,7 @@ public function testCustomBlockTypeEditing() { $this->createCustomBlockType('other'); $instance = field_info_instance('custom_block', 'body', 'basic'); - $this->assertEqual($instance->getFieldLabel(), 'Block body', 'Body field was found.'); + $this->assertEqual($instance->getLabel(), 'Block body', 'Body field was found.'); // Verify that title and body fields are displayed. $this->drupalGet('block/add/basic'); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index a740e57d0f0a..1b8a1b7d5588 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -241,8 +241,8 @@ function comment_count_unpublished() { * Implements hook_ENTITY_TYPE_create() for 'field_instance'. */ function comment_field_instance_create(FieldInstanceInterface $instance) { - if ($instance->getFieldType() == 'comment' && !$instance->isSyncing()) { - \Drupal::service('comment.manager')->addBodyField($instance->entity_type, $instance->getFieldName()); + if ($instance->getType() == 'comment' && !$instance->isSyncing()) { + \Drupal::service('comment.manager')->addBodyField($instance->entity_type, $instance->getName()); \Drupal::cache()->delete('comment_entity_info'); // Assign default values for the field instance. $instance->default_value = array(array( @@ -260,7 +260,7 @@ function comment_field_instance_create(FieldInstanceInterface $instance) { * Implements hook_ENTITY_TYPE_update() for 'field_instance'. */ function comment_field_instance_update(FieldInstanceInterface $instance) { - if ($instance->getFieldType() == 'comment') { + if ($instance->getType() == 'comment') { \Drupal::entityManager()->getViewBuilder($instance->entity_type)->resetCache(); } } @@ -269,9 +269,9 @@ function comment_field_instance_update(FieldInstanceInterface $instance) { * Implements hook_ENTITY_TYPE_delete() for 'field_entity'. */ function comment_field_entity_delete(FieldInterface $field) { - if ($field->getFieldType() == 'comment') { + if ($field->getType() == 'comment') { // Delete all fields and displays attached to the comment bundle. - entity_invoke_bundle_hook('delete', 'comment', $field->getFieldName()); + entity_invoke_bundle_hook('delete', 'comment', $field->getName()); \Drupal::cache()->delete('comment_entity_info'); } } @@ -280,11 +280,11 @@ function comment_field_entity_delete(FieldInterface $field) { * Implements hook_ENTITY_TYPE_delete() for 'field_instance'. */ function comment_field_instance_delete(FieldInstanceInterface $instance) { - if ($instance->getFieldType() == 'comment') { + if ($instance->getType() == 'comment') { // Delete all comments that used by the entity bundle. $comments = db_query("SELECT cid FROM {comment} WHERE entity_type = :entity_type AND field_id = :field_id", array( ':entity_type' => $instance->entityType(), - ':field_id' => $instance->entityType() . '__' . $instance->getFieldName(), + ':field_id' => $instance->entityType() . '__' . $instance->getName(), ))->fetchCol(); entity_delete_multiple('comment', $comments); \Drupal::cache()->delete('comment_entity_info'); @@ -368,8 +368,8 @@ function comment_get_recent($number = 10) { */ function comment_new_page_count($num_comments, $new_replies, EntityInterface $entity, $field_name = 'comment') { $instance = \Drupal::service('field.info')->getInstance($entity->entityType(), $entity->bundle(), $field_name); - $mode = $instance->getFieldSetting('default_mode'); - $comments_per_page = $instance->getFieldSetting('per_page'); + $mode = $instance->getSetting('default_mode'); + $comments_per_page = $instance->getSetting('per_page'); $pagenum = NULL; $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { @@ -518,7 +518,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v } // Provide a link to new comment form. if ($commenting_status == COMMENT_OPEN) { - $comment_form_location = $instance->getFieldSetting('form_location'); + $comment_form_location = $instance->getSetting('form_location'); if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -549,7 +549,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v // But we don't want this link if we're building the entity for search // indexing or constructing a search result excerpt. if ($commenting_status == COMMENT_OPEN) { - $comment_form_location = $instance->getFieldSetting('form_location'); + $comment_form_location = $instance->getSetting('form_location'); if (user_access('post comments')) { // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past. @@ -817,7 +817,7 @@ function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) * Implements hook_form_FORM_ID_alter(). */ function comment_form_field_ui_field_instance_edit_form_alter(&$form, $form_state) { - if ($form['#field']->getFieldType() == 'comment') { + if ($form['#field']->getType() == 'comment') { // Collect translation settings. if (\Drupal::moduleHandler()->moduleExists('content_translation')) { array_unshift($form['#submit'], 'comment_translation_configuration_element_submit'); @@ -862,7 +862,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, $form_state) * Implements hook_form_FORM_ID_alter(). */ function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) { - if ($form['#field']->getFieldType() == 'comment') { + if ($form['#field']->getType() == 'comment') { // We only support posting one comment at the time so it doesn't make sense // to let the site builder choose anything else. $form['field']['cardinality_container']['cardinality']['#options'] = drupal_map_assoc(array(1)); @@ -1029,8 +1029,8 @@ function comment_node_update_index(EntityInterface $node, $langcode) { continue; } $instance = \Drupal::service('field.info')->getInstance('node', $node->getType(), $field_name); - $mode = $instance->getFieldSetting('default_mode'); - $comments_per_page = $instance->getFieldSetting('per_page'); + $mode = $instance->getSetting('default_mode'); + $comments_per_page = $instance->getSetting('per_page'); if ($node->get($field_name)->status && $cids = comment_get_thread($node, $field_name, $mode, $comments_per_page)) { $comments = entity_load_multiple('comment', $cids); comment_prepare_thread($comments); @@ -1234,7 +1234,7 @@ function comment_get_display_ordinal($cid, $instance) { $query->condition('c1.status', COMMENT_PUBLISHED); } - if ($instance->getFieldSetting('default_mode') == COMMENT_MODE_FLAT) { + if ($instance->getSetting('default_mode') == COMMENT_MODE_FLAT) { // For flat comments, cid is used for ordering comments due to // unpredictable behavior with timestamp, so we make the same assumption // here. @@ -1266,7 +1266,7 @@ function comment_get_display_ordinal($cid, $instance) { */ function comment_get_display_page($cid, $instance) { $ordinal = comment_get_display_ordinal($cid, $instance); - $comments_per_page = $instance->getFieldSetting('per_page'); + $comments_per_page = $instance->getSetting('per_page'); return floor($ordinal / $comments_per_page); } @@ -1532,7 +1532,7 @@ function theme_comment_post_forbidden($variables) { $instance = \Drupal::service('field.info')->getInstance($entity->entityType(), $entity->bundle(), $field_name); // We cannot use drupal_get_destination() because these links // sometimes appear on /node and taxonomy listing pages. - if ($instance->getFieldSetting('form_location') == COMMENT_FORM_SEPARATE_PAGE) { + if ($instance->getSetting('form_location') == COMMENT_FORM_SEPARATE_PAGE) { $destination = array('destination' => 'comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name . '#comment-form'); } else { diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index c31f53e386bc..10ac40709be1 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -86,7 +86,7 @@ public function form(array $form, array &$form_state) { $form['#id'] = drupal_html_id('comment_form'); $form['#theme'] = array('comment_form__' . $entity->entityType() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form'); - $anonymous_contact = $instance->getFieldSetting('anonymous'); + $anonymous_contact = $instance->getSetting('anonymous'); $is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments'); if (!$this->currentUser->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { @@ -206,7 +206,7 @@ public function form(array $form, array &$form_state) { '#title' => $this->t('Subject'), '#maxlength' => 64, '#default_value' => $comment->subject->value, - '#access' => $instance->getFieldSetting('subject'), + '#access' => $instance->getSetting('subject'), ); // Used for conditional validation of author fields. @@ -233,7 +233,7 @@ protected function actions(array $form, array &$form_state) { $comment = $this->entity; $entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value); $instance = $this->fieldInfo->getInstance($comment->entity_type->value, $entity->bundle(), $comment->field_name->value); - $preview_mode = $instance->getFieldSetting('preview'); + $preview_mode = $instance->getSetting('preview'); // No delete action on the comment form. unset($element['delete']); diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 230bd49c0151..7911daa05b0f 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -278,7 +278,7 @@ protected function alterBuild(array &$build, EntityInterface $comment, EntityDis $commented_entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value); $instance = $this->fieldInfo->getInstance($commented_entity->entityType(), $commented_entity->bundle(), $comment->field_name->value); $is_threaded = isset($comment->divs) - && $instance->getFieldSetting('default_mode') == COMMENT_MODE_THREADED; + && $instance->getSetting('default_mode') == COMMENT_MODE_THREADED; // Add indentation div or close open divs as needed. if ($is_threaded) { diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index e6402aaf34f0..13008f8b5ffa 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -366,12 +366,12 @@ public static function baseFieldDefinitions($entity_type) { $fields['pid'] = FieldDefinition::create('entity_reference') ->setLabel(t('Parent ID')) ->setDescription(t('The parent comment ID if this is a reply to a comment.')) - ->setFieldSetting('target_type', 'comment'); + ->setSetting('target_type', 'comment'); $fields['entity_id'] = FieldDefinition::create('entity_reference') ->setLabel(t('Entity ID')) ->setDescription(t('The ID of the entity of which this comment is a reply.')) - ->setFieldSetting('target_type', 'node') + ->setSetting('target_type', 'node') ->setRequired(TRUE); $fields['langcode'] = FieldDefinition::create('language') @@ -385,7 +385,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['uid'] = FieldDefinition::create('entity_reference') ->setLabel(t('User ID')) ->setDescription(t('The user ID of the comment author.')) - ->setFieldSettings(array( + ->setSettings(array( 'target_type' => 'user', 'default_value' => 0, )); @@ -393,7 +393,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['name'] = FieldDefinition::create('string') ->setLabel(t('Name')) ->setDescription(t("The comment author's name.")) - ->setFieldSetting('default_value', ''); + ->setSetting('default_value', ''); $fields['mail'] = FieldDefinition::create('email') ->setLabel(t('Email')) diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index 5c1d9ea8b6d9..5b4ccc2778d6 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -107,7 +107,7 @@ public function viewElements(FieldItemListInterface $items) { $elements = array(); $output = array(); - $field_name = $this->fieldDefinition->getFieldName(); + $field_name = $this->fieldDefinition->getName(); $entity = $items->getEntity(); $status = $items->status; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php index f4df33a62acd..a68f8db58dc9 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php @@ -95,7 +95,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { $settings = $this->getFieldSettings(); $entity_type = $this->getEntity()->entityType(); - $field_name = $this->getFieldDefinition()->getFieldName(); + $field_name = $this->getFieldDefinition()->getName(); $element['comment'] = array( '#type' => 'details', @@ -164,7 +164,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { public function __get($name) { if ($name == 'status' && !isset($this->values[$name])) { // Get default value from field instance when no data saved in entity. - $field_default_values = $this->getFieldDefinition()->getFieldDefaultValue($this->getEntity()); + $field_default_values = $this->getFieldDefinition()->getDefaultValue($this->getEntity()); return $field_default_values[0]['status']; } else { diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldWidget/CommentWidget.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldWidget/CommentWidget.php index 997b38ef11f4..fd4ece700749 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldWidget/CommentWidget.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldWidget/CommentWidget.php @@ -31,7 +31,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $entity = $items->getParent(); // Get default value from the field instance. - $field_default_values = $this->fieldDefinition->getFieldDefaultValue($entity); + $field_default_values = $this->fieldDefinition->getDefaultValue($entity); $status = $items->status; $element['status'] = array( @@ -57,7 +57,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // If the entity doesn't have any comments, the "hidden" option makes no // sense, so don't even bother presenting it to the user unless this is the // default value widget on the field settings form. - if ($element['#field_parents'] != array('default_value_input') && !$entity->get($field->getFieldName())->comment_count) { + if ($element['#field_parents'] != array('default_value_input') && !$entity->get($field->getName())->comment_count) { $element['status'][COMMENT_HIDDEN]['#access'] = FALSE; // Also adjust the description of the "closed" option. $element['status'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index 7742a6488085..bda6e04e64e2 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -88,8 +88,8 @@ function postComment(EntityInterface $entity, $comment, $subject = '', $contact $edit['comment_body[0][value]'] = $comment; $instance = $this->container->get('field.info')->getInstance('entity_test', 'entity_test', 'comment'); - $preview_mode = $instance->getFieldSetting('preview'); - $subject_mode = $instance->getFieldSetting('subject'); + $preview_mode = $instance->getSetting('preview'); + $subject_mode = $instance->getSetting('subject'); // Must get the page before we test for fields. if ($entity !== NULL) { diff --git a/core/modules/contact/lib/Drupal/contact/Entity/Message.php b/core/modules/contact/lib/Drupal/contact/Entity/Message.php index 8460fb66bce3..f12bbf4628ca 100644 --- a/core/modules/contact/lib/Drupal/contact/Entity/Message.php +++ b/core/modules/contact/lib/Drupal/contact/Entity/Message.php @@ -146,7 +146,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['category'] = FieldDefinition::create('entity_reference') ->setLabel(t('Category ID')) ->setDescription(t('The ID of the associated category.')) - ->setFieldSettings(array('target_type' => 'contact_category')) + ->setSettings(array('target_type' => 'contact_category')) ->setRequired(TRUE); $fields['name'] = FieldDefinition::create('string') @@ -172,7 +172,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['recipient'] = FieldDefinition::create('entity_reference') ->setLabel(t('Recipient ID')) ->setDescription(t('The ID of the recipient user for personal contact messages.')) - ->setFieldSettings(array('target_type' => 'user')); + ->setSettings(array('target_type' => 'user')); return $fields; } diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 8f84d62c7bca..a568182ad04b 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -22,7 +22,7 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field) { $element = array(); - $column_groups = $field->getFieldSetting('column_groups'); + $column_groups = $field->getSetting('column_groups'); if (!empty($column_groups) && count($column_groups) > 1) { $options = array(); $default = array(); @@ -34,7 +34,7 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field) $settings = array('dependent_selectors' => array('instance[settings][translation_sync]' => array('file'))); - $translation_sync = $field->getFieldSetting('translation_sync'); + $translation_sync = $field->getSetting('translation_sync'); $element = array( '#type' => 'checkboxes', '#title' => t('Translatable elements'), @@ -101,10 +101,10 @@ function _content_translation_form_language_content_settings_form_alter(array &$ // translation. // @todo Remove this special casing as soon as configurable and // base field definitions are "unified". - if ($definition->isFieldConfigurable() && ($field = FieldService::fieldInfo()->getField($entity_type, $field_name))) { + if ($definition->isConfigurable() && ($field = FieldService::fieldInfo()->getField($entity_type, $field_name))) { $instance = FieldService::fieldInfo()->getInstance($entity_type, $bundle, $field_name); $form['settings'][$entity_type][$bundle]['fields'][$field_name] = array( - '#label' => $instance->getFieldLabel(), + '#label' => $instance->getLabel(), '#type' => 'checkbox', '#default_value' => $translatable, ); @@ -122,7 +122,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ // fields support translation. Whether they are actually enabled is // determined through our settings. As a consequence only fields // that support translation can be enabled or disabled. - elseif (isset($field_settings[$field_name]) || $definition->isFieldTranslatable()) { + elseif (isset($field_settings[$field_name]) || $definition->isTranslatable()) { $form['settings'][$entity_type][$bundle]['fields'][$field_name] = array( '#label' => $definition->getLabel(), '#type' => 'checkbox', @@ -347,7 +347,7 @@ function _content_translation_update_field_translatability($settings) { // If translatability changes for at least one field instance we need // to switch field translatability. $field = FieldService::fieldInfo()->getField($entity_type, $field_name); - if ($field && $field->isFieldTranslatable() !== $translatable) { + if ($field && $field->isTranslatable() !== $translatable) { $fields[$field_name] = $translatable; } } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 7f5074e8fc1a..73dcca9325bf 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -630,7 +630,7 @@ function content_translation_form_alter(array &$form, array &$form_state) { if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) { foreach ($entity->getPropertyDefinitions() as $property_name => $definition) { if (isset($form[$property_name])) { - $form[$property_name]['#multilingual'] = $definition->isFieldTranslatable(); + $form[$property_name]['#multilingual'] = $definition->isTranslatable(); } } } @@ -795,7 +795,7 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, a $form['field']['translatable'] = array( '#type' => 'checkbox', '#title' => t('Users may translate this field.'), - '#default_value' => $form['#field']->isFieldTranslatable(), + '#default_value' => $form['#field']->isTranslatable(), '#weight' => 20, ); $form['#submit'][] = 'content_translation_form_field_ui_field_edit_form_submit'; @@ -810,7 +810,7 @@ function content_translation_form_field_ui_field_edit_form_submit($form, array & if (!isset($value)) { $value = array(); } - $value[$instance->getField()->getFieldName()] = $form_state['values']['field']['translatable']; + $value[$instance->getField()->getName()] = $form_state['values']['field']['translatable']; // Store the same value for all bundles as translatability is tracked per // field. foreach (entity_get_bundles($instance->entity_type) as $bundle => $info) { @@ -822,7 +822,7 @@ function content_translation_form_field_ui_field_edit_form_submit($form, array & * Implements hook_form_FORM_ID_alter() for 'field_ui_field_instance_edit_form'. */ function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state, $form_id) { - if ($form['#field']->isFieldTranslatable()) { + if ($form['#field']->isTranslatable()) { module_load_include('inc', 'content_translation', 'content_translation.admin'); $element = content_translation_field_sync_widget($form['#field']); if ($element) { @@ -1008,7 +1008,7 @@ function content_translation_save_settings($settings) { if (!empty($bundle_settings['columns'])) { foreach ($bundle_settings['columns'] as $field_name => $column_settings) { $instance = field_info_instance($entity_type, $field_name, $bundle); - if ($instance->isFieldTranslatable()) { + if ($instance->isTranslatable()) { $instance->settings['translation_sync'] = $column_settings; } // If the field does not have translatable enabled we need to reset diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index efb66159df08..fca8b9a55da7 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -43,7 +43,7 @@ function content_translation_overview(EntityInterface $entity) { // Determine whether the current entity is translatable. $translatable = FALSE; foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) { - if ($instance->isFieldTranslatable()) { + if ($instance->isTranslatable()) { $translatable = TRUE; break; } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 21290a633841..8486b161e28f 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -60,7 +60,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode // Sync when the field is not empty, when the synchronization translations // setting is set, and the field is translatable. - $translation_sync = $instance->getFieldSetting('translation_sync'); + $translation_sync = $instance->getSetting('translation_sync'); if (!$entity->get($field_name)->isEmpty() && !empty($translation_sync) && field_is_translatable($entity_type, $field)) { // Retrieve all the untranslatable column groups and merge them into // single list. @@ -68,7 +68,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode if (!empty($groups)) { $columns = array(); foreach ($groups as $group) { - $column_groups = $field->getFieldSetting('column_groups'); + $column_groups = $field->getSetting('column_groups'); $info = $column_groups[$group]; // A missing 'columns' key indicates we have a single-column group. $columns = array_merge($columns, isset($info['columns']) ? $info['columns'] : array($group)); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 77c4f7d89ba3..33ecd9a75871 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -92,7 +92,7 @@ function testSettingsUI() { $this->assertSettings('comment', 'node__comment_article', TRUE, $edit); field_info_cache_clear(); $field = field_info_field('comment', 'comment_body'); - $this->assertTrue($field->isFieldTranslatable(), 'Comment body is translatable.'); + $this->assertTrue($field->isTranslatable(), 'Comment body is translatable.'); // Test that language settings are correctly stored. $language_configuration = language_get_default_configuration('comment', 'node__comment_article'); @@ -132,8 +132,8 @@ function testSettingsUI() { $this->assertSettings('node', 'article', TRUE, $edit); $field = FieldService::fieldInfo()->getField('node', 'body'); $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); - $this->assertEqual($definitions['body']->isFieldTranslatable(), $translatable, 'Field translatability correctly switched.'); - $this->assertEqual($field->isFieldTranslatable(), $definitions['body']->isFieldTranslatable(), 'Configurable field translatability correctly switched.'); + $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); + $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); // Test that also the Field UI form behaves correctly. $translatable = !$translatable; @@ -143,8 +143,8 @@ function testSettingsUI() { entity_info_cache_clear(); $field = FieldService::fieldInfo()->getField('node', 'body'); $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); - $this->assertEqual($definitions['body']->isFieldTranslatable(), $translatable, 'Field translatability correctly switched.'); - $this->assertEqual($field->isFieldTranslatable(), $definitions['body']->isFieldTranslatable(), 'Configurable field translatability correctly switched.'); + $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); + $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); } } diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index 78f187445d78..1f0c81e2a5e8 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -191,11 +191,11 @@ function datetime_default_value($entity, $field, $instance, $langcode) { $value = ''; $date = ''; - if ($instance->getFieldSetting('default_value') == 'now') { + if ($instance->getSetting('default_value') == 'now') { // A default value should be in the format and timezone used for date // storage. $date = new DrupalDateTime('now', DATETIME_STORAGE_TIMEZONE); - $storage_format = $field->getFieldSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT; + $storage_format = $field->getSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT; $value = $date->format($storage_format); } diff --git a/core/modules/datetime/lib/Drupal/datetime/DateTimeComputed.php b/core/modules/datetime/lib/Drupal/datetime/DateTimeComputed.php index 5d134f1c81ac..271cba94cc30 100644 --- a/core/modules/datetime/lib/Drupal/datetime/DateTimeComputed.php +++ b/core/modules/datetime/lib/Drupal/datetime/DateTimeComputed.php @@ -48,7 +48,7 @@ public function getValue($langcode = NULL) { $item = $this->getParent(); $value = $item->{($this->definition->getSetting('date source'))}; - $storage_format = $item->getFieldDefinition()->getFieldSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT; + $storage_format = $item->getFieldDefinition()->getSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT; try { $date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE); if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { diff --git a/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php index 827014937d46..8ac86fcc08ac 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php +++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php @@ -43,7 +43,7 @@ public function setUp() { )); $this->field->save(); $this->instance = entity_create('field_instance', array( - 'field_name' => $this->field->getFieldName(), + 'field_name' => $this->field->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'settings' => array( diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php index 7b5ab90157e6..9f125a55a87b 100644 --- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php +++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php @@ -177,7 +177,7 @@ protected function buildEntity(array $form, array &$form_state) { // @todo Refine automated log messages and abstract them to all entity // types: http://drupal.org/node/1678002. if ($entity->entityType() == 'node' && $entity->isNewRevision() && !isset($entity->log)) { - $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getFieldLabel())); + $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel())); } return $entity; diff --git a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php index 2c2740960782..4f18ed4cb9f3 100644 --- a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php +++ b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php @@ -68,7 +68,7 @@ public function generateEntity(EntityInterface $entity, $langcode) { * {@inheritdoc} */ public function generateField(EntityInterface $entity, FieldDefinitionInterface $field_definition, $langcode, $view_mode) { - $field_name = $field_definition->getFieldName(); + $field_name = $field_definition->getName(); // Early-return if user does not have access. $access = $this->accessChecker->accessEditEntityField($entity, $field_name); @@ -85,7 +85,7 @@ public function generateField(EntityInterface $entity, FieldDefinitionInterface } // Gather metadata, allow the editor to add additional metadata of its own. - $label = $field_definition->getFieldLabel(); + $label = $field_definition->getLabel(); $editor = $this->editorManager->createInstance($editor_id); $metadata = array( 'label' => check_plain($label), diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php index 0842b605d6e4..4f294d10a32d 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php @@ -28,11 +28,11 @@ class PlainTextEditor extends EditorBase { */ function isCompatible(FieldDefinitionInterface $field_definition, array $items) { // This editor is incompatible with multivalued fields. - if ($field_definition->getFieldCardinality() != 1) { + if ($field_definition->getCardinality() != 1) { return FALSE; } // This editor is incompatible with processed ("rich") text fields. - elseif ($field_definition->getFieldSetting('text_processing')) { + elseif ($field_definition->getSetting('text_processing')) { return FALSE; } else { diff --git a/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php b/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php index 8224110dde6e..e4f96ed26251 100644 --- a/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php +++ b/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php @@ -26,13 +26,13 @@ class WysiwygEditor extends EditorBase { */ function isCompatible(FieldDefinitionInterface $field_definition, array $items) { // This editor is incompatible with multivalued fields. - if ($field_definition->getFieldCardinality() != 1) { + if ($field_definition->getCardinality() != 1) { return FALSE; } // This editor is compatible with processed ("rich") text fields; but only // if there is a currently active text format and that text format is the // 'full_html' text format. - elseif ($field_definition->getFieldSetting('text_processing')) { + elseif ($field_definition->getSetting('text_processing')) { $format_id = $items[0]['format']; if (isset($format_id) && $format_id === 'full_html') { return TRUE; diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 5684ad0cddfc..837544f443f2 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -557,7 +557,7 @@ function _editor_get_processed_text_fields(ContentEntityInterface $entity) { // Find all configurable fields, because only they could have a // text_processing setting. $configurable_fields = array_keys(array_filter($properties, function ($definition) { - return $definition->isFieldConfigurable(); + return $definition->isConfigurable(); })); if (empty($configurable_fields)) { return array(); @@ -567,7 +567,7 @@ function _editor_get_processed_text_fields(ContentEntityInterface $entity) { return array_filter($configurable_fields, function ($field) use ($entity) { $settings = Field::fieldInfo() ->getInstance($entity->entityType(), $entity->bundle(), $field) - ->getFieldSettings(); + ->getSettings(); return isset($settings['text_processing']) && $settings['text_processing'] === '1'; }); } diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php index 1064cbfd5885..55b0549b91bd 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php @@ -28,13 +28,13 @@ class Editor extends PluginBase implements EditPluginInterface { */ function isCompatible(FieldDefinitionInterface $field_definition, array $items) { // This editor is incompatible with multivalued fields. - if ($field_definition->getFieldCardinality() != 1) { + if ($field_definition->getCardinality() != 1) { return FALSE; } // This editor is compatible with processed ("rich") text fields; but only // if there is a currently active text format, that text format has an // associated editor and that editor supports inline editing. - elseif ($field_definition->getFieldSetting('text_processing')) { + elseif ($field_definition->getSetting('text_processing')) { $format_id = $items[0]['format']; if (isset($format_id) && $editor = editor_load($format_id)) { $definition = \Drupal::service('plugin.manager.editor')->getDefinition($editor->editor); diff --git a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php index 5b0ff2462fed..e61b39bd7092 100644 --- a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php +++ b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php @@ -56,7 +56,7 @@ public function getConstraints() { 'value' => array( 'Length' => array( 'max' => static::EMAIL_MAX_LENGTH, - 'maxMessage' => t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@max' => static::EMAIL_MAX_LENGTH)), + 'maxMessage' => t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => static::EMAIL_MAX_LENGTH)), ) ), )); diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 68fa68228209..e96959ff3f05 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -254,7 +254,6 @@ public function setComponent($name, array $options = array()) { $max = $this->getHighestWeight(); $options['weight'] = isset($max) ? $max + 1 : 0; } - // See remark in getComponent(). // @todo Cleanup after https://drupal.org/node/2144919 is fixed. $extra_fields = field_info_extra_fields($this->targetEntityType, $this->bundle, $this->displayContext); @@ -262,7 +261,7 @@ public function setComponent($name, array $options = array()) { $options['visible'] = TRUE; } elseif ($field_definition = $this->getFieldDefinition($name)) { - $options = $this->pluginManager->prepareConfiguration($field_definition->getFieldType(), $options); + $options = $this->pluginManager->prepareConfiguration($field_definition->getType(), $options); } // Clear the persisted plugin, if any. diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index d52ba4c95071..e44cc325279f 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -51,7 +51,7 @@ function entity_reference_field_entity_update(FieldInterface $field) { return; } - if ($field->getFieldSetting('target_type') == $field->original->getFieldSetting('target_type')) { + if ($field->getSetting('target_type') == $field->original->getSetting('target_type')) { // Target type didn't change. return; } @@ -61,7 +61,7 @@ function entity_reference_field_entity_update(FieldInterface $field) { return; } - $field_name = $field->getFieldName(); + $field_name = $field->getName(); foreach ($field->bundles() as $entity_type => $bundles) { foreach ($bundles as $bundle) { @@ -153,7 +153,7 @@ function entity_reference_options_list(FieldDefinitionInterface $field_definitio } // Rebuild the array by changing the bundle key into the bundle label. - $target_type = $field_definition->getFieldSetting('target_type'); + $target_type = $field_definition->getSetting('target_type'); $bundles = entity_get_bundles($target_type); $return = array(); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php index bf58a7fe07c5..15c625c86eea 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php @@ -26,7 +26,7 @@ class ConfigurableEntityReferenceItem extends ConfigEntityReferenceItemBase impl * {@inheritdoc} */ public static function schema(FieldInterface $field) { - $target_type = $field->getFieldSetting('target_type'); + $target_type = $field->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); if (is_subclass_of($target_type_info['class'], '\Drupal\Core\Entity\ContentEntityInterface')) { @@ -137,7 +137,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { '#type' => 'select', '#title' => t('Reference method'), '#options' => $handlers_options, - '#default_value' => $instance->getFieldSetting('handler'), + '#default_value' => $instance->getSetting('handler'), '#required' => TRUE, '#ajax' => TRUE, '#limit_validation_errors' => array(), diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php index 96909a905305..e49373d9be90 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php @@ -85,7 +85,7 @@ public function getMatches($field, $instance, $entity_type, $entity_id = '', $pr if (isset($string)) { // Get an array of matching entities. - $widget = entity_get_form_display($instance->entity_type, $instance->bundle, 'default')->getComponent($instance->getFieldName()); + $widget = entity_get_form_display($instance->entity_type, $instance->bundle, 'default')->getComponent($instance->getName()); $match_operator = !empty($widget['settings']['match_operator']) ? $widget['settings']['match_operator'] : 'CONTAINS'; $entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php index be332520fbd9..6ee2db4879dd 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php @@ -87,7 +87,7 @@ public function handleAutocomplete(Request $request, $type, $field_name, $entity } $access_controller = $this->entityManager->getAccessController($entity_type); - if ($instance->getFieldType() != 'entity_reference' || !$access_controller->fieldAccess('edit', $instance)) { + if ($instance->getType() != 'entity_reference' || !$access_controller->fieldAccess('edit', $instance)) { throw new AccessDeniedHttpException(); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php index 80a0f6f3200e..9623c436e6e0 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php @@ -33,7 +33,7 @@ protected function getDefaultValue() { } } if ($uuids) { - $target_type = $this->getFieldDefinition()->getFieldSetting('target_type'); + $target_type = $this->getFieldDefinition()->getSetting('target_type'); $entity_ids = \Drupal::entityQuery($target_type) ->condition('uuid', $uuids, 'IN') ->execute(); @@ -80,7 +80,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, array &$fo $ids[] = $properties['target_id']; } $entities = \Drupal::entityManager() - ->getStorageController($this->getFieldDefinition()->getFieldSetting('target_type')) + ->getStorageController($this->getFieldDefinition()->getSetting('target_type')) ->loadMultiple($ids); foreach ($default_value as $delta => $properties) { diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php index 9880f328c92e..301ee9a2083e 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php @@ -76,7 +76,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Prepare the autocomplete route parameters. $autocomplete_route_parameters = array( 'type' => $this->getSetting('autocomplete_type'), - 'field_name' => $this->fieldDefinition->getFieldName(), + 'field_name' => $this->fieldDefinition->getName(), 'entity_type' => $entity->entityType(), 'bundle_name' => $entity->bundle(), ); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php index 88c9dd90789b..391f0f069f85 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php @@ -54,8 +54,8 @@ public function createInstance($plugin_id, array $configuration = array()) { * Overrides \Drupal\Component\Plugin\PluginManagerBase::getInstance(). */ public function getInstance(array $options) { - $selection_handler = $options['field_definition']->getFieldSetting('handler'); - $target_entity_type = $options['field_definition']->getFieldSetting('target_type'); + $selection_handler = $options['field_definition']->getSetting('handler'); + $target_entity_type = $options['field_definition']->getSetting('target_type'); // Get all available selection plugins for this entity type. $selection_handler_groups = $this->getSelectionGroups($target_entity_type); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php index 99eba590f00a..fb0beb7f2926 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php @@ -55,8 +55,8 @@ public function __construct(FieldDefinitionInterface $field_definition, EntityIn * {@inheritdoc} */ public static function settingsForm(FieldDefinitionInterface $field_definition) { - $target_type = $field_definition->getFieldSetting('target_type'); - $selection_handler_settings = $field_definition->getFieldSetting('handler_settings') ?: array(); + $target_type = $field_definition->getSetting('target_type'); + $selection_handler_settings = $field_definition->getSetting('handler_settings') ?: array(); $entity_info = \Drupal::entityManager()->getDefinition($target_type); $bundles = entity_get_bundles($target_type); @@ -110,7 +110,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) foreach (field_info_instances($target_type) as $bundle_instances) { foreach ($bundle_instances as $instance_name => $instance) { foreach ($instance->getField()->getColumns() as $column_name => $column_info) { - $fields[$instance_name . '.' . $column_name] = t('@label (@column)', array('@label' => $instance->getFieldLabel(), '@column' => $column_name)); + $fields[$instance_name . '.' . $column_name] = t('@label (@column)', array('@label' => $instance->getLabel(), '@column' => $column_name)); } } @@ -159,7 +159,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) * {@inheritdoc} */ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { - $target_type = $this->fieldDefinition->getFieldSetting('target_type'); + $target_type = $this->fieldDefinition->getSetting('target_type'); $query = $this->buildEntityQuery($match, $match_operator); if ($limit > 0) { @@ -198,7 +198,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON public function validateReferenceableEntities(array $ids) { $result = array(); if ($ids) { - $target_type = $this->fieldDefinition->getFieldSetting('target_type'); + $target_type = $this->fieldDefinition->getSetting('target_type'); $entity_info = entity_get_info($target_type); $query = $this->buildEntityQuery(); $result = $query @@ -258,8 +258,8 @@ public function validateAutocompleteInput($input, &$element, &$form_state, $form * it. */ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { - $target_type = $this->fieldDefinition->getFieldSetting('target_type'); - $handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings'); + $target_type = $this->fieldDefinition->getSetting('target_type'); + $handler_settings = $this->fieldDefinition->getSetting('handler_settings'); $entity_info = entity_get_info($target_type); $query = \Drupal::entityQuery($target_type); @@ -272,7 +272,7 @@ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { } // Add entity-access tag. - $query->addTag($this->fieldDefinition->getFieldSetting('target_type') . '_access'); + $query->addTag($this->fieldDefinition->getSetting('target_type') . '_access'); // Add the Selection handler for // entity_reference_query_entity_reference_alter(). @@ -281,7 +281,7 @@ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { $query->addMetaData('entity_reference_selection_handler', $this); // Add the sort option. - $handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings'); + $handler_settings = $this->fieldDefinition->getSetting('handler_settings'); if (!empty($handler_settings['sort'])) { $sort_settings = $handler_settings['sort']; if ($sort_settings['field'] != '_none') { diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index c252e2ed05a7..c0a8c8ee5f36 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -210,7 +210,7 @@ function hook_field_widget_info_alter(array &$info) { function hook_field_widget_form_alter(&$element, &$form_state, $context) { // Add a css class to widget form elements for all fields of type mytype. $field_definition = $context['items']->getFieldDefinition(); - if ($field_definition->getFieldType() == 'mytype') { + if ($field_definition->getType() == 'mytype') { // Be sure not to overwrite existing attributes. $element['#attributes']['class'][] = 'myclass'; } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 70f197b1fb7e..50b3cb2683a9 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -96,7 +96,7 @@ function field_invoke_method($method, $target_function, EntityInterface $entity, $target = call_user_func($target_function, $field_definition); if (method_exists($target, $method)) { - $items = $entity->get($field_definition->getFieldName()); + $items = $entity->get($field_definition->getName()); $items->filterEmptyValues(); $result = $target->$method($items, $a, $b); @@ -159,7 +159,7 @@ function field_invoke_method_multiple($method, $target_function, array $entities $field_definitions = _field_invoke_get_field_definitions($entity_type, $bundle, $options); foreach ($field_definitions as $field_definition) { - $field_name = $field_definition->getFieldName(); + $field_name = $field_definition->getName(); $group_key = "$bundle:$field_name"; // Let the closure determine the target object on which the method should @@ -259,7 +259,7 @@ function _field_invoke_get_field_definitions($entity_type, $bundle, $options) { */ function _field_invoke_widget_target($form_display) { return function (FieldDefinitionInterface $field_definition) use ($form_display) { - return $form_display->getRenderer($field_definition->getFieldName()); + return $form_display->getRenderer($field_definition->getName()); }; } diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index 6cfb42f74f1e..9578f3d320c4 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -599,7 +599,7 @@ function field_attach_form_validate(ContentEntityInterface $entity, $form, &$for $has_violations = FALSE; foreach ($entity as $field_name => $field) { $definition = $field->getDefinition(); - if ($definition->isFieldConfigurable() && (empty($options['field_name']) || $options['field_name'] == $field_name)) { + if ($definition->isConfigurable() && (empty($options['field_name']) || $options['field_name'] == $field_name)) { $field_violations = $field->validate(); if (count($field_violations)) { $has_violations = TRUE; @@ -699,7 +699,7 @@ function field_attach_prepare_view($entity_type, array $entities, array $display // the entity display. $target_function = function (FieldDefinitionInterface $field_definition, $bundle) use ($displays) { if (isset($displays[$bundle])) { - return $displays[$bundle]->getRenderer($field_definition->getFieldName()); + return $displays[$bundle]->getRenderer($field_definition->getName()); } }; $null = NULL; @@ -738,7 +738,7 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan // For each field, call the view() method on the formatter object handed // by the entity display. $target_function = function (FieldDefinitionInterface $field_definition) use ($display) { - return $display->getRenderer($field_definition->getFieldName()); + return $display->getRenderer($field_definition->getName()); }; $null = NULL; $output = field_invoke_method('view', $target_function, $entity, $null, $null, $options); @@ -799,10 +799,10 @@ function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL) * The default value for the field. * * @deprecated as of Drupal 8.0. Use - * $instance->getFieldDefaultValue($entity) + * $instance->getDefaultValue($entity) */ function field_get_default_value(EntityInterface $entity, $field, $instance, $langcode = NULL) { - return $instance->getFieldDefaultValue($entity); + return $instance->getDefaultValue($entity); } /** @@ -900,13 +900,13 @@ function field_language(EntityInterface $entity, $field_name = NULL, $langcode = if (!isset($field_name)) { $display_langcodes = array(); foreach ($definitions as $name => $definition) { - if ($definition->isFieldConfigurable()) { + if ($definition->isConfigurable()) { $display_langcodes[$name] = $translatable ? $langcode : Language::LANGCODE_NOT_SPECIFIED; } } return $display_langcodes; } - elseif ($definitions[$field_name]->isFieldConfigurable()) { + elseif ($definitions[$field_name]->isConfigurable()) { return $translatable ? $langcode : Language::LANGCODE_NOT_SPECIFIED; } } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index cef1cad76697..2c9c2a75b728 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -225,7 +225,7 @@ function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) { $instances = field_read_instances(); foreach ($instances as $instance) { if ($instance->entity_type == $entity_type && $instance->bundle == $bundle_old) { - $id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->getFieldName(); + $id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->getName(); $instance->id = $id_new; $instance->bundle = $bundle_new; $instance->allowBundleRename(); @@ -437,7 +437,7 @@ function field_view_field(ContentEntityInterface $entity, $field_name, $display_ // hook_field_attach_display_alter() needs to receive the 'prepared' // $display_options, so we cannot let preparation happen internally. $formatter_manager = Drupal::service('plugin.manager.field.formatter'); - $display_options = $formatter_manager->prepareConfiguration($field_definition->getFieldType(), $display_options); + $display_options = $formatter_manager->prepareConfiguration($field_definition->getType(), $display_options); $formatter = $formatter_manager->getInstance(array( 'field_definition' => $field_definition, 'view_mode' => $view_mode, diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc index 2ea2bf161bae..8565e9656698 100644 --- a/core/modules/field/field.multilingual.inc +++ b/core/modules/field/field.multilingual.inc @@ -88,7 +88,7 @@ function field_available_languages($entity_type, FieldInterface $field) { $drupal_static_fast['field_langcodes'] = &drupal_static(__FUNCTION__); } $field_langcodes = &$drupal_static_fast['field_langcodes']; - $field_name = $field->getFieldName(); + $field_name = $field->getName(); if (!isset($field_langcodes[$entity_type][$field_name])) { // If the field has language support enabled we retrieve an (alterable) list @@ -167,7 +167,7 @@ function field_content_languages() { * TRUE if the field can be translated. */ function field_is_translatable($entity_type, FieldInterface $field) { - return $field->isFieldTranslatable() && field_has_translation_handler($entity_type); + return $field->isTranslatable() && field_has_translation_handler($entity_type); } /** diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index a061b5fab6a1..e6df06463f72 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -171,7 +171,7 @@ function field_purge_instance($instance) { function field_purge_field($field) { $instances = field_read_instances(array('field_id' => $field->uuid()), array('include_deleted' => 1)); if (count($instances) > 0) { - throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getFieldName()))); + throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getName()))); } $state = \Drupal::state(); diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc index ae8787393e87..7def00e61a8d 100644 --- a/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -90,7 +90,7 @@ function field_views_field_label($entity_type, $field_name) { foreach ($instances as $bundle => $bundle_instances) { if (isset($bundle_instances[$field_name])) { $instance = $bundle_instances[$field_name]; - $label = $instance->getFieldLabel(); + $label = $instance->getLabel(); $label_counter[$label] = isset($label_counter[$label]) ? ++$label_counter[$label] : 1; $all_labels[$label] = TRUE; } @@ -117,7 +117,7 @@ function field_views_field_default_views_data(FieldInterface $field) { $data = array(); // Check the field type is available. - if (!\Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getFieldType())) { + if (!\Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType())) { return $data; } // Check the field has instances. @@ -125,7 +125,7 @@ function field_views_field_default_views_data(FieldInterface $field) { return $data; } - $field_name = $field->getFieldName(); + $field_name = $field->getName(); $field_columns = $field->getColumns(); // Grab information about the entity type tables. @@ -375,7 +375,7 @@ function field_views_field_default_views_data(FieldInterface $field) { } // Expose additional delta column for multiple value fields. - if ($field->isFieldMultiple()) { + if ($field->isMultiple()) { $title_delta = t('@label (!name:delta)', array('@label' => $label, '!name' => $field_name)); $title_short_delta = t('@label:delta', array('@label' => $label)); @@ -417,7 +417,7 @@ function field_views_field_default_views_data(FieldInterface $field) { } // Expose additional language column for translatable fields. - if ($field->isFieldTranslatable()) { + if ($field->isTranslatable()) { $title_language = t('@label (!name:language)', array('@label' => $label, '!name' => $field_name)); $title_short_language = t('@label:language', array('@label' => $label)); @@ -474,7 +474,7 @@ function list_field_views_data($field) { $data[$table_name][$field_name]['filter']['id'] = 'field_list'; } if (isset($field_data['argument']) && $field_name != 'delta') { - if ($field->getFieldType() == 'list_text') { + if ($field->getType() == 'list_text') { $data[$table_name][$field_name]['argument']['id'] = 'field_list_string'; } else { diff --git a/core/modules/field/lib/Drupal/field/Entity/Field.php b/core/modules/field/lib/Drupal/field/Entity/Field.php index 4929e4b1423b..e1f89e24b166 100644 --- a/core/modules/field/lib/Drupal/field/Entity/Field.php +++ b/core/modules/field/lib/Drupal/field/Entity/Field.php @@ -500,21 +500,21 @@ public function getBundles() { /** * {@inheritdoc} */ - public function getFieldName() { + public function getName() { return $this->name; } /** * {@inheritdoc} */ - public function getFieldType() { + public function getType() { return $this->type; } /** * {@inheritdoc} */ - public function getFieldSettings() { + public function getSettings() { // @todo field_info_field_types() calls _field_info_collate_types() which // maintains its own static cache. However, do some CPU and memory // profiling to see if it's worth statically caching $field_type_info, or @@ -528,12 +528,12 @@ public function getFieldSettings() { /** * {@inheritdoc} */ - public function getFieldSetting($setting_name) { - // @todo See getFieldSettings() about potentially statically caching this. + public function getSetting($setting_name) { + // @todo See getSettings() about potentially statically caching this. $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->type); // We assume here that consecutive array_key_exists() is more efficient than - // calling getFieldSettings() when all we need is a single setting. + // calling getSettings() when all we need is a single setting. if (array_key_exists($setting_name, $this->settings)) { return $this->settings[$setting_name]; } @@ -551,7 +551,7 @@ public function getFieldSetting($setting_name) { /** * {@inheritdoc} */ - public function getFieldPropertyNames() { + public function getPropertyNames() { $schema = $this->getSchema(); return array_keys($schema['columns']); } @@ -559,7 +559,7 @@ public function getFieldPropertyNames() { /** * {@inheritdoc} */ - public function isFieldTranslatable() { + public function isTranslatable() { return $this->translatable; } @@ -580,55 +580,55 @@ public function setTranslatable($translatable) { /** * {@inheritdoc} */ - public function getFieldLabel() { + public function getLabel() { return $this->label(); } /** * {@inheritdoc} */ - public function getFieldDescription() { + public function getDescription() { return NULL; } /** * {@inheritdoc} */ - public function getFieldCardinality() { + public function getCardinality() { return $this->cardinality; } /** * {@inheritdoc} */ - public function isFieldRequired() { + public function isRequired() { return FALSE; } /** * {@inheritdoc} */ - public function isFieldMultiple() { - $cardinality = $this->getFieldCardinality(); + public function isMultiple() { + $cardinality = $this->getCardinality(); return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1); } /** * {@inheritdoc} */ - public function getFieldDefaultValue(EntityInterface $entity) { } + public function getDefaultValue(EntityInterface $entity) { } /** * {@inheritdoc} */ - public function isFieldConfigurable() { + public function isConfigurable() { return TRUE; } /** * {@inheritdoc} */ - public function isFieldQueryable() { + public function isQueryable() { return TRUE; } @@ -704,20 +704,6 @@ public function getDataType() { return 'list'; } - /** - * {@inheritdoc} - */ - public function getLabel() { - return $this->label(); - } - - /** - * {@inheritdoc} - */ - public function getDescription() { - return $this->getFieldDescription(); - } - /** * {@inheritdoc} */ @@ -739,47 +725,16 @@ public function isComputed() { return FALSE; } - /** - * {@inheritdoc} - */ - public function isRequired() { - return $this->isFieldRequired(); - } - /** * {@inheritdoc} */ public function getClass() { // Derive list class from the field type. $type_definition = \Drupal::service('plugin.manager.field.field_type') - ->getDefinition($this->getFieldType()); + ->getDefinition($this->getType()); return $type_definition['list_class']; } - /** - * {@inheritdoc} - */ - public function getSettings() { - // This should actually return the settings for field item list, which are - // not the field settings. However, there is no harm in returning field - // settings here, so we do that to avoid confusion for now. - // @todo: Unify with getFieldSettings() or remove once typed data moved - // to the adapter approach. - return $this->getFieldSettings(); - } - - /** - * {@inheritdoc} - */ - public function getSetting($setting_name) { - // This should actually return the settings for field item list, which are - // not the field settings. However, there is no harm in returning field - // settings here, so we do that to avoid confusion for now. - // @todo: Unify with getFieldSettings() or remove once typed data moved - // to the adapter approach. - return $this->getFieldSetting($setting_name); - } - /** * {@inheritdoc} */ @@ -800,7 +755,7 @@ public function getConstraint($constraint_name) { public function getItemDefinition() { if (!isset($this->itemDefinition)) { $this->itemDefinition = DataDefinition::create('field_item:' . $this->type) - ->setSettings($this->getFieldSettings()); + ->setSettings($this->getSettings()); } return $this->itemDefinition; } diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php index 3af2671df0b9..23c7d188a32e 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php @@ -454,40 +454,40 @@ public function getField() { /** * {@inheritdoc} */ - public function getFieldName() { + public function getName() { return $this->field->name; } /** * {@inheritdoc} */ - public function getFieldType() { + public function getType() { return $this->field->type; } /** * {@inheritdoc} */ - public function getFieldSettings() { - return $this->settings + $this->field->getFieldSettings(); + public function getSettings() { + return $this->settings + $this->field->getSettings(); } /** * {@inheritdoc} */ - public function getFieldSetting($setting_name) { + public function getSetting($setting_name) { if (array_key_exists($setting_name, $this->settings)) { return $this->settings[$setting_name]; } else { - return $this->field->getFieldSetting($setting_name); + return $this->field->getSetting($setting_name); } } /** * {@inheritdoc} */ - public function getFieldPropertyNames() { + public function getPropertyNames() { $schema = $this->field->getSchema(); return array_keys($schema['columns']); } @@ -495,7 +495,7 @@ public function getFieldPropertyNames() { /** * {@inheritdoc} */ - public function isFieldTranslatable() { + public function isTranslatable() { return $this->field->translatable; } @@ -522,42 +522,42 @@ public function uri() { /** * {@inheritdoc} */ - public function getFieldLabel() { + public function getLabel() { return $this->label(); } /** * {@inheritdoc} */ - public function getFieldDescription() { + public function getDescription() { return $this->description; } /** * {@inheritdoc} */ - public function getFieldCardinality() { + public function getCardinality() { return $this->field->cardinality; } /** * {@inheritdoc} */ - public function isFieldRequired() { + public function isRequired() { return $this->required; } /** * {@inheritdoc} */ - public function isFieldMultiple() { - return $this->field->isFieldMultiple(); + public function isMultiple() { + return $this->field->isMultiple(); } /** * {@inheritdoc} */ - public function getFieldDefaultValue(EntityInterface $entity) { + public function getDefaultValue(EntityInterface $entity) { if (!empty($this->default_value_function)) { $function = $this->default_value_function; return $function($entity, $this->getField(), $this, $entity->language()->id); @@ -570,14 +570,14 @@ public function getFieldDefaultValue(EntityInterface $entity) { /** * {@inheritdoc} */ - public function isFieldConfigurable() { + public function isConfigurable() { return TRUE; } /** * {@inheritdoc} */ - public function isFieldQueryable() { + public function isQueryable() { return TRUE; } @@ -613,20 +613,6 @@ public function getDataType() { return 'list'; } - /** - * {@inheritdoc} - */ - public function getLabel() { - return $this->label(); - } - - /** - * {@inheritdoc} - */ - public function getDescription() { - return $this->getFieldDescription(); - } - /** * {@inheritdoc} */ @@ -648,14 +634,6 @@ public function isComputed() { return FALSE; } - /** - * {@inheritdoc} - */ - public function isRequired() { - // Only field instances can be required. - return $this->isFieldRequired(); - } - /** * {@inheritdoc} */ @@ -663,20 +641,6 @@ public function getClass() { return $this->field->getClass(); } - /** - * {@inheritdoc} - */ - public function getSettings() { - return $this->getFieldSettings(); - } - - /** - * {@inheritdoc} - */ - public function getSetting($setting_name) { - return $this->getFieldSetting($setting_name); - } - /** * {@inheritdoc} */ @@ -697,7 +661,7 @@ public function getConstraint($constraint_name) { public function getItemDefinition() { if (!isset($this->itemDefinition)) { $this->itemDefinition = DataDefinition::create('field_item:' . $this->field->type) - ->setSettings($this->getFieldSettings()); + ->setSettings($this->getSettings()); } return $this->itemDefinition; } diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 6adc77606070..7abc9db0b87b 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -242,7 +242,7 @@ public function getFields() { // Fill the name/ID map. foreach ($this->fieldsById as $field) { if (!$field->deleted) { - $this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid(); + $this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid(); } } @@ -279,7 +279,7 @@ public function getInstances($entity_type = NULL) { foreach (field_read_instances() as $instance) { $instance = $this->prepareInstance($instance); - $this->bundleInstances[$instance->entity_type][$instance->bundle][$instance->getFieldName()] = $instance; + $this->bundleInstances[$instance->entity_type][$instance->bundle][$instance->getName()] = $instance; } // Store in persistent cache. @@ -366,7 +366,7 @@ public function getFieldById($field_id) { // Store in the static cache. $this->fieldsById[$field->uuid()] = $field; if (!$field->deleted) { - $this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid(); + $this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid(); } return $field; @@ -410,7 +410,7 @@ public function getBundleInstances($entity_type, $bundle) { if (!isset($this->fieldsById[$field->uuid()])) { $this->fieldsById[$field->uuid()] = $field; if (!$field->deleted) { - $this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid(); + $this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid(); } } } @@ -458,7 +458,7 @@ public function getBundleInstances($entity_type, $bundle) { $field = $this->prepareField($field); $this->fieldsById[$field->uuid()] = $field; - $this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid(); + $this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid(); } $fields[] = $this->fieldsById[$field->uuid()]; @@ -468,7 +468,7 @@ public function getBundleInstances($entity_type, $bundle) { $loaded_instances = entity_load_multiple('field_instance', array_values($config_ids)); foreach ($loaded_instances as $instance) { $instance = $this->prepareInstance($instance); - $instances[$instance->getFieldName()] = $instance; + $instances[$instance->getName()] = $instance; } } } @@ -560,7 +560,7 @@ public function getBundleExtraFields($entity_type, $bundle) { */ public function prepareField(FieldInterface $field) { // Make sure all expected field settings are present. - $field->settings += $this->fieldTypeManager->getDefaultSettings($field->getFieldType()); + $field->settings += $this->fieldTypeManager->getDefaultSettings($field->getType()); return $field; } @@ -576,7 +576,7 @@ public function prepareField(FieldInterface $field) { */ public function prepareInstance(FieldInstanceInterface $instance) { // Make sure all expected instance settings are present. - $instance->settings += $this->fieldTypeManager->getDefaultInstanceSettings($instance->getFieldType()); + $instance->settings += $this->fieldTypeManager->getDefaultInstanceSettings($instance->getType()); return $instance; } diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 293095a39359..9bbb6caf7fcf 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -143,8 +143,8 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o $this->multiple = FALSE; $this->limit_values = FALSE; - $cardinality = $this->field_info->getFieldCardinality(); - if ($this->field_info->isFieldMultiple()) { + $cardinality = $this->field_info->getCardinality(); + if ($this->field_info->isMultiple()) { $this->multiple = TRUE; // If "Display all values in the same row" is FALSE, then we always limit @@ -325,7 +325,7 @@ protected function defineOptions() { // defineOptions runs before init/construct, so no $this->field_info $field = field_info_field($this->definition['entity_type'], $this->definition['field_name']); - $field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getFieldType()); + $field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType()); $column_names = array_keys($field->getColumns()); $default_column = ''; // Try to determine a sensible default. @@ -361,7 +361,7 @@ protected function defineOptions() { // If we know the exact number of allowed values, then that can be // the default. Otherwise, default to 'all'. $options['delta_limit'] = array( - 'default' => ($field->getFieldCardinality() > 1) ? $field->getFieldCardinality() : 'all', + 'default' => ($field->getCardinality() > 1) ? $field->getCardinality() : 'all', ); $options['delta_offset'] = array( 'default' => 0, @@ -397,7 +397,7 @@ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); $field = $this->field_info; - $formatters = $this->formatterPluginManager->getOptions($field->getFieldType()); + $formatters = $this->formatterPluginManager->getOptions($field->getType()); $column_names = array_keys($field->getColumns()); // If this is a multiple value field, add its options. @@ -496,14 +496,14 @@ function multiple_options_form(&$form, &$form_state) { // translating prefix and suffix separately. list($prefix, $suffix) = explode('@count', t('Display @count value(s)')); - if ($field->getFieldCardinality() == FieldDefinitionInterface::CARDINALITY_UNLIMITED) { + if ($field->getCardinality() == FieldDefinitionInterface::CARDINALITY_UNLIMITED) { $type = 'textfield'; $options = NULL; $size = 5; } else { $type = 'select'; - $options = drupal_map_assoc(range(1, $field->getFieldCardinality())); + $options = drupal_map_assoc(range(1, $field->getCardinality())); $size = 1; } $form['multi_type'] = array( diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php index f95c7aebd0cb..f194d1c3a7fd 100644 --- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php @@ -143,7 +143,7 @@ function setUp() { for ($i = 0; $i < 10; $i++) { $entity = entity_create($this->entity_type, array('type' => $bundle)); foreach ($this->fields as $field) { - $entity->{$field->getFieldName()}->setValue($this->_generateTestFieldValues($field->getFieldCardinality())); + $entity->{$field->getName()}->setValue($this->_generateTestFieldValues($field->getCardinality())); } $entity->save(); } diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 702cbdd07d0d..e29969f86292 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -44,8 +44,8 @@ function testCreateField() { $field = entity_create('field_entity', $field_definition); $field->save(); $mem = field_test_memorize(); - $this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getFieldName(), $field_definition['name'], 'hook_entity_create() called with correct arguments.'); - $this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getFieldType(), $field_definition['type'], 'hook_entity_create() called with correct arguments.'); + $this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getName(), $field_definition['name'], 'hook_entity_create() called with correct arguments.'); + $this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getType(), $field_definition['type'], 'hook_entity_create() called with correct arguments.'); // Read the configuration. Check against raw configuration data rather than // the loaded ConfigEntity, to be sure we check that the defaults are @@ -349,13 +349,13 @@ function testDeleteField() { // Save an entity with data for the field $entity = entity_create('entity_test', array()); $values[0]['value'] = mt_rand(1, 127); - $entity->{$field->getFieldName()}->value = $values[0]['value']; + $entity->{$field->getName()}->value = $values[0]['value']; $entity = $this->entitySaveReload($entity); // Verify the field is present on load - $this->assertIdentical(count($entity->{$field->getFieldName()}), count($values), "Data in previously deleted field saves and loads correctly"); + $this->assertIdentical(count($entity->{$field->getName()}), count($values), "Data in previously deleted field saves and loads correctly"); foreach ($values as $delta => $value) { - $this->assertEqual($entity->{$field->getFieldName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly"); + $this->assertEqual($entity->{$field->getName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly"); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 23e7fd1ad942..8f773733acfb 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -51,9 +51,9 @@ function testFieldAttachView() { $entity_init = entity_create($entity_type, array()); // Populate values to be displayed. - $values = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values = $this->_generateTestFieldValues($this->field->getCardinality()); $entity_init->{$this->field_name}->setValue($values); - $values_2 = $this->_generateTestFieldValues($this->field_2->getFieldCardinality()); + $values_2 = $this->_generateTestFieldValues($this->field_2->getCardinality()); $entity_init->{$this->field_name_2}->setValue($values_2); // Simple formatter, label displayed. @@ -69,7 +69,7 @@ function testFieldAttachView() { 'test_formatter_setting' => $formatter_setting, ), ); - $display->setComponent($this->field->getFieldName(), $display_options); + $display->setComponent($this->field->getName(), $display_options); $formatter_setting_2 = $this->randomName(); $display_options_2 = array( @@ -79,19 +79,19 @@ function testFieldAttachView() { 'test_formatter_setting' => $formatter_setting_2, ), ); - $display->setComponent($this->field_2->getFieldName(), $display_options_2); + $display->setComponent($this->field_2->getName(), $display_options_2); // View all fields. field_attach_prepare_view($entity_type, array($entity->id() => $entity), $displays); $content = field_attach_view($entity, $display); $output = drupal_render($content); $this->content = $output; - $this->assertRaw($this->instance->getFieldLabel(), "First field's label is displayed."); + $this->assertRaw($this->instance->getLabel(), "First field's label is displayed."); foreach ($values as $delta => $value) { $this->content = $output; $this->assertRaw("$formatter_setting|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); } - $this->assertRaw($this->instance_2->getFieldLabel(), "Second field's label is displayed."); + $this->assertRaw($this->instance_2->getLabel(), "Second field's label is displayed."); foreach ($values_2 as $delta => $value) { $this->content = $output; $this->assertRaw("$formatter_setting_2|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); @@ -100,21 +100,21 @@ function testFieldAttachView() { // Label hidden. $entity = clone($entity_init); $display_options['label'] = 'hidden'; - $display->setComponent($this->field->getFieldName(), $display_options); + $display->setComponent($this->field->getName(), $display_options); field_attach_prepare_view($entity_type, array($entity->id() => $entity), $displays); $entity->content = field_attach_view($entity, $display); $output = drupal_render($entity->content); $this->content = $output; - $this->assertNoRaw($this->instance->getFieldLabel(), "Hidden label: label is not displayed."); + $this->assertNoRaw($this->instance->getLabel(), "Hidden label: label is not displayed."); // Field hidden. $entity = clone($entity_init); - $display->removeComponent($this->field->getFieldName()); + $display->removeComponent($this->field->getName()); field_attach_prepare_view($entity_type, array($entity->id() => $entity), $displays); $entity->content = field_attach_view($entity, $display); $output = drupal_render($entity->content); $this->content = $output; - $this->assertNoRaw($this->instance->getFieldLabel(), "Hidden field: label is not displayed."); + $this->assertNoRaw($this->instance->getLabel(), "Hidden field: label is not displayed."); foreach ($values as $delta => $value) { $this->assertNoRaw("$formatter_setting|{$value['value']}", "Hidden field: value $delta is not displayed."); } @@ -122,7 +122,7 @@ function testFieldAttachView() { // Multiple formatter. $entity = clone($entity_init); $formatter_setting = $this->randomName(); - $display->setComponent($this->field->getFieldName(), array( + $display->setComponent($this->field->getName(), array( 'label' => 'above', 'type' => 'field_test_multiple', 'settings' => array( @@ -142,7 +142,7 @@ function testFieldAttachView() { // Test a formatter that uses hook_field_formatter_prepare_view(). $entity = clone($entity_init); $formatter_setting = $this->randomName(); - $display->setComponent($this->field->getFieldName(), array( + $display->setComponent($this->field->getName(), array( 'label' => 'above', 'type' => 'field_test_with_prepare_view', 'settings' => array( @@ -182,7 +182,7 @@ function testFieldAttachPrepareViewMultiple() { // Set the instance to be hidden. $display = entity_get_display('entity_test', 'entity_test', 'full') - ->removeComponent($this->field->getFieldName()); + ->removeComponent($this->field->getName()); // Set up a second instance on another bundle, with a formatter that uses // hook_field_formatter_prepare_view(). @@ -194,7 +194,7 @@ function testFieldAttachPrepareViewMultiple() { $this->instance2->save(); $display_2 = entity_get_display('entity_test', 'test_bundle_2', 'full') - ->setComponent($this->field->getFieldName(), array( + ->setComponent($this->field->getName(), array( 'type' => 'field_test_with_prepare_view', 'settings' => array( 'test_formatter_setting_additional' => $formatter_setting, @@ -205,11 +205,11 @@ function testFieldAttachPrepareViewMultiple() { // Create one entity in each bundle. $entity1_init = entity_create('entity_test', array('id' => 1, 'type' => 'entity_test')); - $values1 = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values1 = $this->_generateTestFieldValues($this->field->getCardinality()); $entity1_init->{$this->field_name}->setValue($values1); $entity2_init = entity_create('entity_test', array('id' => 2, 'type' => 'test_bundle_2')); - $values2 = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values2 = $this->_generateTestFieldValues($this->field->getCardinality()); $entity2_init->{$this->field_name}->setValue($values2); // Run prepare_view, and check that the entities come out as expected. @@ -236,7 +236,7 @@ function testFieldAttachCache() { // Initialize random values and a test entity. $entity_init = entity_create('entity_test', array('type' => $this->instance->bundle)); $langcode = Language::LANGCODE_NOT_SPECIFIED; - $values = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values = $this->_generateTestFieldValues($this->field->getCardinality()); // Non-cacheable entity type. $entity_type = 'entity_test'; @@ -280,7 +280,7 @@ function testFieldAttachCache() { $this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, 'Cached: correct cache entry on load'); // Update with different values, and check that the cache entry is wiped. - $values = $this->_generateTestFieldValues($this->field_2->getFieldCardinality()); + $values = $this->_generateTestFieldValues($this->field_2->getCardinality()); $entity = entity_create($entity_type, array( 'type' => $entity_type, 'id' => $entity->id(), @@ -300,7 +300,7 @@ function testFieldAttachCache() { 'type' => $entity_type, 'id' => $entity->id(), )); - $values = $this->_generateTestFieldValues($this->field_2->getFieldCardinality()); + $values = $this->_generateTestFieldValues($this->field_2->getCardinality()); $entity->{$this->field_name_2} = $values; $entity->setNewRevision(); $entity->save(); @@ -335,13 +335,13 @@ function testFieldAttachForm() { $form_state['form_display'] = entity_get_form_display($entity_type, $this->instance->bundle, 'default'); field_attach_form($entity, $form, $form_state); - $this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getFieldLabel(), "First field's form title is {$this->instance->getFieldLabel()}"); - $this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getFieldLabel(), "Second field's form title is {$this->instance_2->getFieldLabel()}"); - for ($delta = 0; $delta < $this->field->getFieldCardinality(); $delta++) { + $this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getLabel(), "First field's form title is {$this->instance->getLabel()}"); + $this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getLabel(), "Second field's form title is {$this->instance_2->getLabel()}"); + for ($delta = 0; $delta < $this->field->getCardinality(); $delta++) { // field_test_widget uses 'textfield' $this->assertEqual($form[$this->field_name]['widget'][$delta]['value']['#type'], 'textfield', "First field's form delta $delta widget is textfield"); } - for ($delta = 0; $delta < $this->field_2->getFieldCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) { // field_test_widget uses 'textfield' $this->assertEqual($form[$this->field_name_2]['widget'][$delta]['value']['#type'], 'textfield', "Second field's form delta $delta widget is textfield"); } @@ -354,8 +354,8 @@ function testFieldAttachForm() { field_attach_form($entity, $form, $form_state, NULL, $options); $this->assertFalse(isset($form[$this->field_name]), 'The first field does not exist in the form'); - $this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getFieldLabel(), "Second field's form title is {$this->instance_2->getFieldLabel()}"); - for ($delta = 0; $delta < $this->field_2->getFieldCardinality(); $delta++) { + $this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getLabel(), "Second field's form title is {$this->instance_2->getLabel()}"); + for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) { // field_test_widget uses 'textfield' $this->assertEqual($form[$this->field_name_2]['widget'][$delta]['value']['#type'], 'textfield', "Second field's form delta $delta widget is textfield"); } @@ -380,11 +380,11 @@ function testFieldAttachExtractFormValues() { // First field. $values = array(); $weights = array(); - for ($delta = 0; $delta < $this->field->getFieldCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field->getCardinality(); $delta++) { $values[$delta]['value'] = mt_rand(1, 127); // Assign random weight. do { - $weight = mt_rand(0, $this->field->getFieldCardinality()); + $weight = mt_rand(0, $this->field->getCardinality()); } while (in_array($weight, $weights)); $weights[$delta] = $weight; $values[$delta]['_weight'] = $weight; @@ -394,11 +394,11 @@ function testFieldAttachExtractFormValues() { // Second field. $values_2 = array(); $weights_2 = array(); - for ($delta = 0; $delta < $this->field_2->getFieldCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) { $values_2[$delta]['value'] = mt_rand(1, 127); // Assign random weight. do { - $weight = mt_rand(0, $this->field_2->getFieldCardinality()); + $weight = mt_rand(0, $this->field_2->getCardinality()); } while (in_array($weight, $weights_2)); $weights_2[$delta] = $weight; $values_2[$delta]['_weight'] = $weight; diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 3f0b74381f15..ddd26a27c759 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -48,7 +48,7 @@ public function setUp() { function testFieldAttachSaveLoad() { $entity_type = 'entity_test_rev'; $this->createFieldWithInstance('', $entity_type); - $cardinality = $this->field->getFieldCardinality(); + $cardinality = $this->field->getCardinality(); // Configure the instance so that we test // \Drupal\field_test\Plugin\Field\FieldType\TestItem::getCacheData(). @@ -248,7 +248,7 @@ function testFieldAttachSaveEmptyDataDefaultValue() { function testFieldAttachDelete() { $entity_type = 'entity_test_rev'; $this->createFieldWithInstance('', $entity_type); - $cardinality = $this->field->getFieldCardinality(); + $cardinality = $this->field->getCardinality(); $entity = entity_create($entity_type, array('type' => $this->instance->bundle)); $vids = array(); @@ -306,7 +306,7 @@ function testFieldAttachDelete() { function testEntityCreateRenameBundle() { $entity_type = 'entity_test_rev'; $this->createFieldWithInstance('', $entity_type); - $cardinality = $this->field->getFieldCardinality(); + $cardinality = $this->field->getCardinality(); // Create a new bundle. $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomName()); @@ -376,7 +376,7 @@ function testEntityDeleteBundle() { // Save an entity with data for both fields $entity = entity_create($entity_type, array('type' => $this->instance->bundle)); - $values = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values = $this->_generateTestFieldValues($this->field->getCardinality()); $entity->{$this->field_name} = $values; $entity->{$field_name} = $this->_generateTestFieldValues(1); $entity = $this->entitySaveReload($entity); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldImportChangeTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldImportChangeTest.php index ca941e98e706..f7e001f189b5 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldImportChangeTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldImportChangeTest.php @@ -52,7 +52,7 @@ function testImportChange() { // Check that the updated config was correctly imported. $instance = entity_load('field_instance', $instance_id); - $this->assertEqual($instance->getFieldLabel(), $new_label, 'Instance label updated'); + $this->assertEqual($instance->getLabel(), $new_label, 'Instance label updated'); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index 2c7f8e3cb728..b1b9346cb706 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -49,18 +49,18 @@ function testFieldInfo() { $field->save(); $fields = field_info_fields(); $this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists'); - $this->assertEqual($fields[$field->uuid]->getFieldName(), $field->getFieldName(), 'info fields contains field name'); - $this->assertEqual($fields[$field->uuid]->getFieldType(), $field->getFieldType(), 'info fields contains field type'); + $this->assertEqual($fields[$field->uuid]->getName(), $field->getName(), 'info fields contains field name'); + $this->assertEqual($fields[$field->uuid]->getType(), $field->getType(), 'info fields contains field type'); $this->assertEqual($fields[$field->uuid]->module, 'field_test', 'info fields contains field module'); $settings = array('test_field_setting' => 'dummy test string'); foreach ($settings as $key => $val) { - $this->assertEqual($fields[$field->uuid]->getFieldSetting($key), $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val))); + $this->assertEqual($fields[$field->uuid]->getSetting($key), $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val))); } - $this->assertEqual($fields[$field->uuid]->getFieldCardinality(), 1, 'info fields contains cardinality 1'); + $this->assertEqual($fields[$field->uuid]->getCardinality(), 1, 'info fields contains cardinality 1'); // Create an instance, verify that it shows up $instance_definition = array( - 'field_name' => $field->getFieldName(), + 'field_name' => $field->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $this->randomName(), @@ -75,7 +75,7 @@ function testFieldInfo() { $this->assertEqual(count($instances), 1, format_string('One instance shows up in info when attached to a bundle on a @label.', array( '@label' => $info['label'] ))); - $this->assertTrue($instance_definition < $instances[$instance->getFieldName()], 'Instance appears in info correctly'); + $this->assertTrue($instance_definition < $instances[$instance->getName()], 'Instance appears in info correctly'); // Test a valid entity type but an invalid bundle. $instances = field_info_instances('entity_test', 'invalid_bundle'); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php index 6af6dcbb2c0a..7bcf53244c0c 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php @@ -51,7 +51,7 @@ function setUp() { $this->field = entity_create('field_entity', $this->field_definition); $this->field->save(); $this->instance_definition = array( - 'field_name' => $this->field->getFieldName(), + 'field_name' => $this->field->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', ); @@ -115,7 +115,7 @@ function testReadFieldInstance() { // Read the instance back. $instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue($this->instance_definition['field_name'] == $instance->getFieldName(), 'The field was properly read.'); + $this->assertTrue($this->instance_definition['field_name'] == $instance->getName(), 'The field was properly read.'); $this->assertTrue($this->instance_definition['entity_type'] == $instance->entity_type, 'The field was properly read.'); $this->assertTrue($this->instance_definition['bundle'] == $instance->bundle, 'The field was properly read.'); } @@ -128,16 +128,16 @@ function testUpdateFieldInstance() { // Check that basic changes are saved. $instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $instance->required = !$instance->isFieldRequired(); + $instance->required = !$instance->isRequired(); $instance->label = $this->randomName(); $instance->description = $this->randomName(); $instance->settings['test_instance_setting'] = $this->randomName(); $instance->save(); $instance_new = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance->isFieldRequired(), $instance_new->isFieldRequired(), '"required" change is saved'); - $this->assertEqual($instance->getFieldLabel(), $instance_new->getFieldLabel(), '"label" change is saved'); - $this->assertEqual($instance->getFieldDescription(), $instance_new->getFieldDescription(), '"description" change is saved'); + $this->assertEqual($instance->isRequired(), $instance_new->isRequired(), '"required" change is saved'); + $this->assertEqual($instance->getLabel(), $instance_new->getLabel(), '"label" change is saved'); + $this->assertEqual($instance->getDescription(), $instance_new->getDescription(), '"description" change is saved'); // TODO: test failures. } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldValidationTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldValidationTest.php index 5a740d1c276c..547beab0d21f 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldValidationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldValidationTest.php @@ -54,14 +54,14 @@ function testCardinalityConstraint() { // Check that the expected constraint violations are reported. $this->assertEqual(count($violations), 1); $this->assertEqual($violations[0]->getPropertyPath(), ''); - $this->assertEqual($violations[0]->getMessage(), t('%name: this field cannot hold more than @count values.', array('%name' => $this->instance->getFieldLabel(), '@count' => $cardinality))); + $this->assertEqual($violations[0]->getMessage(), t('%name: this field cannot hold more than @count values.', array('%name' => $this->instance->getLabel(), '@count' => $cardinality))); } /** * Tests that constraints defined by the field type are validated. */ function testFieldConstraints() { - $cardinality = $this->field->getFieldCardinality(); + $cardinality = $this->field->getCardinality(); $entity = $this->entity; // The test is only valid if the field cardinality is greater than 2. @@ -76,7 +76,7 @@ function testFieldConstraints() { } else { $value = -1; - $expected_violations[$delta . '.value'][] = t('%name does not accept the value -1.', array('%name' => $this->instance->getFieldLabel())); + $expected_violations[$delta . '.value'][] = t('%name does not accept the value -1.', array('%name' => $this->instance->getLabel())); } $entity->{$this->field_name}->offsetGet($delta)->set('value', $value); } diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php index 0f57fcefa20d..81ec2ffbb349 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php @@ -615,7 +615,7 @@ function testHiddenField() { $this->instance->default_value = NULL; $this->instance->save(); entity_get_form_display($entity_type, $this->instance->bundle, 'default') - ->setComponent($this->instance->getFieldName(), array( + ->setComponent($this->instance->getName(), array( 'type' => 'test_field_widget', )) ->save(); @@ -635,7 +635,7 @@ function testHiddenField() { // Set the field back to hidden. entity_get_form_display($entity_type, $this->instance->bundle, 'default') - ->removeComponent($this->instance->getFieldName()) + ->removeComponent($this->instance->getName()) ->save(); // Create a new revision. diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 0c02b4ff17f4..a105e90a503e 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -164,7 +164,7 @@ function testTranslatableFieldSaveLoad() { $available_langcodes = array_keys(language_list()); $entity->langcode->value = reset($available_langcodes); foreach ($available_langcodes as $langcode) { - $field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); $entity->getTranslation($langcode)->{$this->field_name}->setValue($field_translations[$langcode]); } @@ -201,7 +201,7 @@ function testTranslatableFieldSaveLoad() { $values = array('type' => $instance->bundle, 'langcode' => $translation_langcodes[0]); $entity = entity_create($entity_type, $values); foreach ($translation_langcodes as $langcode) { - $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); $entity->getTranslation($langcode, FALSE)->{$this->field_name}->setValue($values[$this->field_name][$langcode]); } @@ -219,7 +219,7 @@ function testTranslatableFieldSaveLoad() { $values = array('type' => $instance->bundle, 'langcode' => $translation_langcodes[0]); $entity = entity_create($entity_type, $values); foreach ($translation_langcodes as $langcode) { - $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getFieldCardinality()); + $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); $entity->getTranslation($langcode)->{$this->field_name}->setValue($values[$this->field_name][$langcode]); $entity->getTranslation($langcode)->{$field_name_default}->setValue($empty_items); $values[$field_name_default][$langcode] = $empty_items; diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php index 90d3ef7c592a..fc9f3bed9e52 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php @@ -106,7 +106,7 @@ function testFieldFormTranslationRevisions() { $available_langcodes = array_flip(field_available_languages($this->entity_type, $this->field)); unset($available_langcodes[Language::LANGCODE_NOT_SPECIFIED]); unset($available_langcodes[Language::LANGCODE_NOT_APPLICABLE]); - $field_name = $this->field->getFieldName(); + $field_name = $this->field->getName(); // Store the field translations. ksort($available_langcodes); @@ -135,7 +135,7 @@ function testFieldFormTranslationRevisions() { * by the passed arguments were correctly stored. */ private function checkTranslationRevisions($id, $revision_id, $available_langcodes) { - $field_name = $this->field->getFieldName(); + $field_name = $this->field->getName(); $entity = entity_revision_load($this->entity_type, $revision_id); foreach ($available_langcodes as $langcode => $value) { $passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1; diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php index 54135e192e8c..22d0b88db999 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php @@ -75,7 +75,7 @@ function setUpFields($amount = 3) { function setUpInstances($bundle = 'page') { foreach ($this->fields as $key => $field) { $instance = array( - 'field_name' => $field->getFieldName(), + 'field_name' => $field->getName(), 'entity_type' => 'node', 'bundle' => 'page', ); diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php index ce4fa3a52a9d..850edc106281 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php @@ -73,13 +73,13 @@ protected function setUp() { for ($key = 0; $key < 3; $key++) { $field = $this->fields[$key]; - $edit[$field->getFieldName()][0]['value'] = $this->randomName(8); + $edit[$field->getName()][0]['value'] = $this->randomName(8); } for ($j = 0; $j < 5; $j++) { - $edit[$this->fields[3]->getFieldName()][$j]['value'] = $this->randomName(8); + $edit[$this->fields[3]->getName()][$j]['value'] = $this->randomName(8); } // Set this field to be empty. - $edit[$this->fields[4]->getFieldName()] = array(array('value' => NULL)); + $edit[$this->fields[4]->getName()] = array(array('value' => NULL)); $this->nodes[$i] = $this->drupalCreateNode($edit); } @@ -96,7 +96,7 @@ protected function setUp() { protected function prepareView(ViewExecutable $view) { $view->initDisplay(); foreach ($this->fields as $field) { - $field_name = $field->getFieldName(); + $field_name = $field->getName(); $view->display_handler->options['fields'][$field_name]['id'] = $field_name; $view->display_handler->options['fields'][$field_name]['table'] = 'node__' . $field_name; $view->display_handler->options['fields'][$field_name]['field'] = $field_name; @@ -117,7 +117,7 @@ public function _testSimpleFieldRender() { // Tests that the rendered fields match the actual value of the fields. for ($i = 0; $i < 3; $i++) { for ($key = 0; $key < 2; $key++) { - $field_name = $this->fields[$key]->getFieldName(); + $field_name = $this->fields[$key]->getName(); $rendered_field = $view->style_plugin->getField($i, $field_name); $expected_field = $this->nodes[$i]->$field_name->value; $this->assertEqual($rendered_field, $expected_field); @@ -131,8 +131,8 @@ public function _testSimpleFieldRender() { public function _testFormatterSimpleFieldRender() { $view = views_get_view('test_view_fieldapi'); $this->prepareView($view); - $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getFieldName()]['type'] = 'text_trimmed'; - $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getFieldName()]['settings'] = array( + $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['type'] = 'text_trimmed'; + $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['settings'] = array( 'trim_length' => 3, ); $this->executeView($view); @@ -140,14 +140,14 @@ public function _testFormatterSimpleFieldRender() { // Make sure that the formatter works as expected. // @TODO: actually there should be a specific formatter. for ($i = 0; $i < 2; $i++) { - $rendered_field = $view->style_plugin->getField($i, $this->fields[0]->getFieldName()); + $rendered_field = $view->style_plugin->getField($i, $this->fields[0]->getName()); $this->assertEqual(strlen($rendered_field), 3); } } public function _testMultipleFieldRender() { $view = views_get_view('test_view_fieldapi'); - $field_name = $this->fields[3]->getFieldName(); + $field_name = $this->fields[3]->getName(); // Test delta limit. $this->prepareView($view); @@ -167,8 +167,7 @@ public function _testMultipleFieldRender() { } // Test that an empty field is rendered without error. - $view->style_plugin->getField(4, $this->fields[4]->getFieldName()); - + $view->style_plugin->getField(4, $this->fields[4]->getName()); $view->destroy(); // Test delta limit + offset diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc index f889d85960b8..27768bd5ece0 100644 --- a/core/modules/field/tests/modules/field_test/field_test.field.inc +++ b/core/modules/field/tests/modules/field_test/field_test.field.inc @@ -22,7 +22,7 @@ function field_test_field_widget_info_alter(&$info) { * Implements hook_field_update_forbid(). */ function field_test_field_update_forbid($field, $prior_field) { - if ($field->getFieldType() == 'test_field' && $field->getFieldSetting('unchangeable') != $prior_field->getFieldSetting('unchangeable')) { + if ($field->getType() == 'test_field' && $field->getSetting('unchangeable') != $prior_field->getSetting('unchangeable')) { throw new FieldException("field_test 'unchangeable' setting cannot be changed'"); } } @@ -38,13 +38,13 @@ function field_test_default_value(EntityInterface $entity, $field, $instance) { * Implements hook_entity_field_access(). */ function field_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) { - if ($field_definition->getFieldName() == "field_no_{$operation}_access") { + if ($field_definition->getName() == "field_no_{$operation}_access") { return FALSE; } // Only grant view access to test_view_field fields when the user has // 'view test_view_field content' permission. - if ($field_definition->getFieldName() == 'test_view_field' && $operation == 'view' && !$account->hasPermission('view test_view_field content')) { + if ($field_definition->getName() == 'test_view_field' && $operation == 'view' && !$account->hasPermission('view test_view_field content')) { return FALSE; } diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index c02a40c6b747..d1817c6bd43e 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -142,7 +142,7 @@ function field_test_field_attach_view_alter(&$output, $context) { */ function field_test_field_widget_form_alter(&$element, &$form_state, $context) { $field_definition = $context['items']->getFieldDefinition(); - switch ($field_definition->getFieldName()) { + switch ($field_definition->getName()) { case 'alter_test_text': drupal_set_message('Field size: ' . $context['widget']->getSetting('size')); break; diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php index a32dfa4bff87..fedd03c4544a 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php @@ -56,13 +56,13 @@ public function getPropertyDefinitions() { public static function schema(FieldInterface $field) { $foreign_keys = array(); // The 'foreign keys' key is not always used in tests. - if ($field->getFieldSetting('foreign_key_name')) { + if ($field->getSetting('foreign_key_name')) { $foreign_keys['foreign keys'] = array( // This is a dummy foreign key definition, references a table that // doesn't exist, but that's not a problem. - $field->getFieldSetting('foreign_key_name') => array( - 'table' => $field->getFieldSetting('foreign_key_name'), - 'columns' => array($field->getFieldSetting('foreign_key_name') => 'id'), + $field->getSetting('foreign_key_name') => array( + 'table' => $field->getSetting('foreign_key_name'), + 'columns' => array($field->getSetting('foreign_key_name') => 'id'), ), ); } 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 a92f5170f404..1c1c4e5ef442 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 @@ -137,7 +137,7 @@ public function getConstraints() { 'value' => array( 'TestField' => array( 'value' => -1, - 'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@value' => -1)), + 'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1)), ) ), )); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php index 870df32f70f6..49b161298d0d 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php @@ -57,7 +57,7 @@ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, En $label = array( 'label' => array( '#type' => 'select', - '#title' => $this->t('Label display for @title', array('@title' => $instance->getFieldLabel())), + '#title' => $this->t('Label display for @title', array('@title' => $instance->getLabel())), '#title_display' => 'invisible', '#options' => $this->getFieldLabelOptions(), '#default_value' => $display_options ? $display_options['label'] : 'above', @@ -68,7 +68,7 @@ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, En $field_row = array_slice($field_row, 0, $label_position, TRUE) + $label + array_slice($field_row, $label_position, count($field_row) - 1, TRUE); // Update the (invisible) title of the 'plugin' column. - $field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getFieldLabel())); + $field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getLabel())); if (!empty($field_row['plugin']['settings_edit_form'])) { $plugin_type_info = $entity_display->getRenderer($field_id)->getPluginDefinition(); $field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Format settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>'; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php index 31a08ecfbec6..c24daf26569e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php @@ -221,7 +221,7 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL, */ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, EntityDisplayBaseInterface $entity_display, array $form, array &$form_state) { $display_options = $entity_display->getComponent($field_id); - $label = $instance->getFieldLabel(); + $label = $instance->getLabel(); $field_row = array( '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')), @@ -229,7 +229,7 @@ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, En '#region_callback' => array($this, 'getRowRegion'), '#js_settings' => array( 'rowHandler' => 'field', - 'defaultPlugin' => $this->getDefaultPlugin($instance->getFieldType()), + 'defaultPlugin' => $this->getDefaultPlugin($instance->getType()), ), 'human_name' => array( '#markup' => check_plain($label), @@ -266,7 +266,7 @@ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, En '#type' => 'select', '#title' => $this->t('Plugin for @title', array('@title' => $label)), '#title_display' => 'invisible', - '#options' => $this->getPluginOptions($instance->getFieldType()), + '#options' => $this->getPluginOptions($instance->getType()), '#default_value' => $display_options ? $display_options['type'] : 'hidden', '#parents' => array('fields', $field_id, 'type'), '#attributes' => array('class' => array('field-plugin-type')), diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index b139bb2efe7d..b8c9df2e3c15 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -125,14 +125,14 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL, 'id' => drupal_html_class($name), ), 'label' => array( - '#markup' => check_plain($instance->getFieldLabel()), + '#markup' => check_plain($instance->getLabel()), ), 'field_name' => array( - '#markup' => $instance->getFieldName(), + '#markup' => $instance->getName(), ), 'type' => array( '#type' => 'link', - '#title' => $field_types[$field->getFieldType()]['label'], + '#title' => $field_types[$field->getType()]['label'], '#href' => $admin_field_path . '/field', '#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))), ), @@ -423,7 +423,7 @@ public function submitForm(array &$form, array &$form_state) { $form_state['fields_added']['_add_new_field'] = $values['field_name']; } catch (\Exception $e) { - drupal_set_message($this->t('There was a problem creating field %label: !message', array('%label' => $instance->getFieldLabel(), '!message' => $e->getMessage())), 'error'); + drupal_set_message($this->t('There was a problem creating field %label: !message', array('%label' => $instance->getLabel(), '!message' => $e->getMessage())), 'error'); } } @@ -466,7 +466,7 @@ public function submitForm(array &$form, array &$form_state) { $form_state['fields_added']['_add_existing_field'] = $instance['field_name']; } catch (\Exception $e) { - drupal_set_message($this->t('There was a problem creating field instance %label: @message.', array('%label' => $instance->getFieldLabel(), '@message' => $e->getMessage())), 'error'); + drupal_set_message($this->t('There was a problem creating field instance %label: @message.', array('%label' => $instance->getLabel(), '@message' => $e->getMessage())), 'error'); } } } @@ -515,14 +515,14 @@ protected function getExistingFieldOptions() { // Do not show: // - locked fields, // - fields that should not be added via user interface. - $field_type = $instance->getFieldType(); + $field_type = $instance->getType(); $field = $instance->getField(); if (empty($field->locked) && empty($field_types[$field_type]['no_ui'])) { - $options[$instance->getFieldName()] = array( + $options[$instance->getName()] = array( 'type' => $field_type, 'type_label' => $field_types[$field_type]['label'], - 'field' => $instance->getFieldName(), - 'label' => $instance->getFieldLabel(), + 'field' => $instance->getName(), + 'label' => $instance->getLabel(), ); } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php index f51256bce64c..2b6f5206d434 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php @@ -46,7 +46,7 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete the field %field?', array('%field' => $this->entity->getFieldLabel())); + return $this->t('Are you sure you want to delete the field %field?', array('%field' => $this->entity->getLabel())); } /** 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 555123207313..fa2ba128286c 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 @@ -107,7 +107,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac } // Build the configurable field values. - $cardinality = $field->getFieldCardinality(); + $cardinality = $field->getCardinality(); $form['field']['cardinality_container'] = array( // We can't use the container element because it doesn't support the title // or description properties. @@ -143,8 +143,8 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac ); // Build the non-configurable field values. - $form['field']['field_name'] = array('#type' => 'value', '#value' => $field->getFieldName()); - $form['field']['type'] = array('#type' => 'value', '#value' => $field->getFieldType()); + $form['field']['field_name'] = array('#type' => 'value', '#value' => $field->getName()); + $form['field']['type'] = array('#type' => 'value', '#value' => $field->getType()); $form['field']['module'] = array('#type' => 'value', '#value' => $field->module); // Add settings provided by the field module. The field module is @@ -157,7 +157,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac // FieldItem. $ids = (object) array('entity_type' => $this->instance->entity_type, 'bundle' => $this->instance->bundle, 'entity_id' => NULL); $entity = _field_create_entity_from_ids($ids); - $form['field']['settings'] += $entity->get($field->getFieldName())->offsetGet(0)->settingsForm($form, $form_state, $field->hasData()); + $form['field']['settings'] += $entity->get($field->getName())->offsetGet(0)->settingsForm($form, $form_state, $field->hasData()); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save field settings')); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index 1580fa618a6e..4a811599be7c 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -71,7 +71,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac $bundles = entity_get_bundles(); $form_title = $this->t('%instance settings for %bundle', array( - '%instance' => $this->instance->getFieldLabel(), + '%instance' => $this->instance->getLabel(), '%bundle' => $bundles[$entity_type][$bundle]['label'], )); $form['#title'] = $form_title; @@ -80,11 +80,11 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac // Create an arbitrary entity object (used by the 'default value' widget). $ids = (object) array('entity_type' => $this->instance->entity_type, 'bundle' => $this->instance->bundle, 'entity_id' => NULL); $form['#entity'] = _field_create_entity_from_ids($ids); - $items = $form['#entity']->get($this->instance->getFieldName()); + $items = $form['#entity']->get($this->instance->getName()); if (!empty($field->locked)) { $form['locked'] = array( - '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->instance->getFieldLabel())), + '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->instance->getLabel())), ); return $form; } @@ -97,7 +97,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac // Build the non-configurable instance values. $form['instance']['field_name'] = array( '#type' => 'value', - '#value' => $this->instance->getFieldName(), + '#value' => $this->instance->getName(), ); $form['instance']['entity_type'] = array( '#type' => 'value', @@ -112,7 +112,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac $form['instance']['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), - '#default_value' => $this->instance->getFieldLabel() ?: $field->getFieldName(), + '#default_value' => $this->instance->getLabel() ?: $field->getName(), '#required' => TRUE, '#weight' => -20, ); @@ -120,7 +120,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac $form['instance']['description'] = array( '#type' => 'textarea', '#title' => $this->t('Help text'), - '#default_value' => $this->instance->getFieldDescription(), + '#default_value' => $this->instance->getDescription(), '#rows' => 5, '#description' => $this->t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())) . '<br />' . $this->t('This field supports tokens.'), '#weight' => -10, @@ -129,7 +129,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac $form['instance']['required'] = array( '#type' => 'checkbox', '#title' => $this->t('Required field'), - '#default_value' => $this->instance->isFieldRequired(), + '#default_value' => $this->instance->isRequired(), '#weight' => -5, ); @@ -165,7 +165,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac */ public function validateForm(array &$form, array &$form_state) { if (isset($form['instance']['default_value'])) { - $items = $form['#entity']->get($this->instance->getFieldName()); + $items = $form['#entity']->get($this->instance->getName()); $items->defaultValuesFormValidate($form['instance']['default_value'], $form, $form_state); } } @@ -177,7 +177,7 @@ public function submitForm(array &$form, array &$form_state) { // Handle the default value. $default_value = array(); if (isset($form['instance']['default_value'])) { - $items = $form['#entity']->get($this->instance->getFieldName()); + $items = $form['#entity']->get($this->instance->getName()); $default_value = $items->defaultValuesFormSubmit($form['instance']['default_value'], $form, $form_state); } $this->instance->default_value = $default_value; @@ -188,7 +188,7 @@ public function submitForm(array &$form, array &$form_state) { } $this->instance->save(); - drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->instance->getFieldLabel()))); + drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->instance->getLabel()))); if ($next_destination = FieldUI::getNextDestination($this->getRequest())) { $form_state['redirect'] = $next_destination; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php index 0c4877c7103f..e35b33ab7b13 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php @@ -53,7 +53,7 @@ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, En $field_row = parent::buildFieldRow($field_id, $instance, $entity_display, $form, $form_state); // Update the (invisible) title of the 'plugin' column. - $field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getFieldLabel())); + $field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getLabel())); if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $entity_display->getRenderer($field_id))) { $plugin_type_info = $plugin->getPluginDefinition(); $field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Widget settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>'; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 502aef3fe49a..c593b4b3bb92 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -239,11 +239,11 @@ function assertFieldSettings($bundle, $field_name, $string = 'dummy test string' field_info_cache_clear(); // Assert field settings. $field = field_info_field($entity_type, $field_name); - $this->assertTrue($field->getFieldSetting('test_field_setting') == $string, 'Field settings were found.'); + $this->assertTrue($field->getSetting('test_field_setting') == $string, 'Field settings were found.'); // Assert instance settings. $instance = field_info_instance($entity_type, $field_name, $bundle); - $this->assertTrue($instance->getFieldSetting('test_instance_setting') == $string, 'Field instance settings were found.'); + $this->assertTrue($instance->getSetting('test_instance_setting') == $string, 'Field instance settings were found.'); } /** diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index a42bd78ed4d1..de6350c5e0f2 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -61,7 +61,7 @@ function file_field_widget_multiple_count_validate($element, &$form_state, $form $current = count(element_children(NestedArray::getValue($form, $parents))) - 1; $field = field_info_field($entity_type, $field_name); - $cardinality = $field->getFieldCardinality(); + $cardinality = $field->getCardinality(); $uploaded = count($values['fids']); $count = $uploaded + $current; if ($count > $cardinality) { diff --git a/core/modules/file/file.module b/core/modules/file/file.module index f2b0feffc46e..8c8519532295 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -1881,7 +1881,7 @@ function file_get_file_references(File $file, $field = NULL, $age = EntityStorag // This contains the possible field names. $instances = field_info_instances($entity_type, $bundle); foreach ($instances as $field_name => $instance) { - $field_type = $instance->getFieldType(); + $field_type = $instance->getType(); // If this is the first time this field type is seen, check // whether it references files. if (!isset($field_columns[$field_type])) { @@ -1921,7 +1921,7 @@ function file_get_file_references(File $file, $field = NULL, $age = EntityStorag foreach ($return as $field_name => $data) { foreach (array_keys($data) as $entity_type) { $current_field = field_info_field($entity_type, $field_name); - if (($field_type && $current_field->getFieldType() != $field_type) || ($field && $field->uuid() != $current_field->uuid())) { + if (($field_type && $current_field->getType() != $field_type) || ($field && $field->uuid() != $current_field->uuid())) { unset($return[$field_name][$entity_type]); } } diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index 70131f649990..729ee4b1480f 100644 --- a/core/modules/file/file.views.inc +++ b/core/modules/file/file.views.inc @@ -469,12 +469,12 @@ function file_field_views_data(FieldInterface $field) { $data = field_views_field_default_views_data($field); foreach ($data as $table_name => $table_data) { // Add the relationship only on the fid field. - $data[$table_name][$field->getFieldName() . '_target_id']['relationship'] = array( + $data[$table_name][$field->getName() . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'file_managed', 'entity type' => 'file', 'base field' => 'target_id', - 'label' => t('file from !field_name', array('!field_name' => $field->getFieldName())), + 'label' => t('file from !field_name', array('!field_name' => $field->getName())), ); } @@ -489,7 +489,7 @@ function file_field_views_data(FieldInterface $field) { function file_field_views_data_views_data_alter(array &$data, FieldInterface $field) { $entity_type = $field->entity_type; $entity_info = entity_get_info($entity_type); - $field_name = $field->getFieldName(); + $field_name = $field->getName(); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type; list($label) = field_views_field_label($entity_type, $field_name); diff --git a/core/modules/file/lib/Drupal/file/Entity/File.php b/core/modules/file/lib/Drupal/file/Entity/File.php index 5da26d2429e3..f7bf02323693 100644 --- a/core/modules/file/lib/Drupal/file/Entity/File.php +++ b/core/modules/file/lib/Drupal/file/Entity/File.php @@ -233,7 +233,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['uid'] = FieldDefinition::create('entity_reference') ->setLabel(t('User ID')) ->setDescription(t('The user ID of the file.')) - ->setFieldSetting('target_type', 'user'); + ->setSetting('target_type', 'user'); $fields['filename'] = FieldDefinition::create('string') ->setLabel(t('Filename')) diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php index c9a88abcdd1d..2b750b06f173 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php @@ -53,7 +53,7 @@ public function update() { } // Get the file IDs attached to the field before this update. - $field_name = $this->getFieldDefinition()->getFieldName(); + $field_name = $this->getFieldDefinition()->getName(); $original_fids = array(); $original_items = $entity->original->getTranslation($this->getLangcode())->$field_name; foreach ($original_items as $item) { diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php index 7ce14b8b3f2e..948a06d9a22e 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php @@ -61,7 +61,7 @@ public function settingsSummary() { * Special handling for draggable multiple widgets and 'add more' button. */ protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) { - $field_name = $this->fieldDefinition->getFieldName(); + $field_name = $this->fieldDefinition->getName(); $parents = $form['#parents']; // Load the items for form rebuilds from the field state as they might not be @@ -73,7 +73,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } // Determine the number of widgets to display. - $cardinality = $this->fieldDefinition->getFieldCardinality(); + $cardinality = $this->fieldDefinition->getCardinality(); switch ($cardinality) { case FieldDefinitionInterface::CARDINALITY_UNLIMITED: $max = count($items); @@ -86,8 +86,8 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f break; } - $title = check_plain($this->fieldDefinition->getFieldLabel()); - $description = field_filter_xss($this->fieldDefinition->getFieldDescription()); + $title = check_plain($this->fieldDefinition->getLabel()); + $description = field_filter_xss($this->fieldDefinition->getDescription()); $elements = array(); @@ -183,7 +183,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen 'description_field' => NULL, ); - $cardinality = $this->fieldDefinition->getFieldCardinality(); + $cardinality = $this->fieldDefinition->getCardinality(); $defaults = array( 'fids' => array(), 'display' => (bool) $field_settings['display_default'], diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index 0405c3ab76b0..7a8f3c5ecb68 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -161,7 +161,7 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, // Attach a file to the node. $field = field_info_field('node', $field_name); $name = 'files[' . $field_name . '_0]'; - if ($field->getFieldCardinality() != 1) { + if ($field->getCardinality() != 1) { $name .= '[]'; } $edit[$name] = drupal_realpath($file->getFileUri()); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php index b6d6c4849b43..b85b187dc1da 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -40,7 +40,7 @@ function testRequired() { $edit = array(); $edit['title[0][value]'] = $this->randomName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance->getFieldLabel())), 'Node save failed when required file field was empty.'); + $this->assertRaw(t('!title field is required.', array('!title' => $instance->getLabel())), 'Node save failed when required file field was empty.'); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); @@ -60,7 +60,7 @@ function testRequired() { $edit = array(); $edit['title[0][value]'] = $this->randomName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance->getFieldLabel())), 'Node save failed when required multiple value file field was empty.'); + $this->assertRaw(t('!title field is required.', array('!title' => $instance->getLabel())), 'Node save failed when required multiple value file field was empty.'); // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); diff --git a/core/modules/file/tests/file_module_test/file_module_test.module b/core/modules/file/tests/file_module_test/file_module_test.module index 592bcaab0905..abb16182342e 100644 --- a/core/modules/file/tests/file_module_test/file_module_test.module +++ b/core/modules/file/tests/file_module_test/file_module_test.module @@ -75,7 +75,7 @@ function file_module_test_form_submit($form, &$form_state) { * Implements hook_file_download_access(). */ function file_module_test_file_download_access(FieldInterface $field, EntityInterface $entity, File $file) { - $instance = field_info_instance($entity->entityType(), $field->getFieldName(), $entity->bundle()); + $instance = field_info_instance($entity->entityType(), $field->getName(), $entity->bundle()); // Allow the file to be downloaded only if the given arguments are correct. // If any are wrong, $instance will be NULL. if (empty($instance)) { diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php index 593a501f8d2f..c615933639a7 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php @@ -65,7 +65,7 @@ public function normalize($field_item, $format = NULL, array $context = array()) protected function constructValue($data, $context) { $field_item = $context['target_instance']; $field_definition = $field_item->getFieldDefinition(); - $target_type = $field_definition->getFieldSetting('target_type'); + $target_type = $field_definition->getSetting('target_type'); if ($id = $this->entityResolver->resolve($this, $data, $target_type)) { return array('target_id' => $id); } diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldItemNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldItemNormalizer.php index 2d60eb67c4cd..00222cccd5b4 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldItemNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldItemNormalizer.php @@ -58,7 +58,7 @@ public function denormalize($data, $class, $format = NULL, array $context = arra $langcode = $data['lang']; unset($data['lang']); $field_definition = $field_item->getFieldDefinition(); - if ($field_definition->isFieldTranslatable()) { + if ($field_definition->isTranslatable()) { $field_item = $this->createTranslatedInstance($field_item, $langcode); } } diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php index b53a0910f487..73b5bb91d80e 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php @@ -37,7 +37,7 @@ public function normalize($field, $format = NULL, array $context = array()) { // If this field is not translatable, it can simply be normalized without // separating it into different translations. - if (!$field_definition->isFieldTranslatable()) { + if (!$field_definition->isTranslatable()) { $normalized_field_items = $this->normalizeFieldItems($field, $format, $context); } // Otherwise, the languages have to be extracted from the entity and passed diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index 5babb6a69896..0cd2c6edf96a 100644 --- a/core/modules/image/image.views.inc +++ b/core/modules/image/image.views.inc @@ -20,11 +20,11 @@ function image_field_views_data(FieldInterface $field) { $data = field_views_field_default_views_data($field); foreach ($data as $table_name => $table_data) { // Add the relationship only on the target_id field. - $data[$table_name][$field->getFieldName() . '_target_id']['relationship'] = array( + $data[$table_name][$field->getName() . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'file_managed', 'base field' => 'target_id', - 'label' => t('image from !field_name', array('!field_name' => $field->getFieldName())), + 'label' => t('image from !field_name', array('!field_name' => $field->getName())), ); } @@ -38,7 +38,7 @@ function image_field_views_data(FieldInterface $field) { */ function image_field_views_data_views_data_alter(array &$data, FieldInterface $field) { $entity_type = $field->entity_type; - $field_name = $field->getFieldName(); + $field_name = $field->getName(); $entity_info = entity_get_info($entity_type); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type; diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index baef807ae72e..1b2546501fab 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -147,8 +147,8 @@ protected static function replaceImageStyle(ImageStyleInterface $style) { if ($style->id() != $style->getOriginalId()) { // Loop through all fields searching for image fields. foreach (field_read_instances() as $instance) { - if ($instance->getFieldType() == 'image') { - $field_name = $instance->getFieldName(); + if ($instance->getType() == 'image') { + $field_name = $instance->getName(); $view_modes = array('default') + array_keys(entity_get_view_modes($instance->entity_type)); foreach ($view_modes as $view_mode) { $display = entity_get_display($instance->entity_type, $instance->bundle, $view_mode); diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldFormatter/ImageFormatterBase.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldFormatter/ImageFormatterBase.php index 443c72a02601..6b91e378a3a9 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldFormatter/ImageFormatterBase.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldFormatter/ImageFormatterBase.php @@ -29,7 +29,7 @@ public function prepareView(array $entities_items) { // If we are dealing with a configurable field, look in both // instance-level and field-level settings. if (empty($default_image['fid']) && $this->fieldDefinition instanceof FieldInstanceInterface) { - $default_image = $this->fieldDefinition->getField()->getFieldSetting('default_image'); + $default_image = $this->fieldDefinition->getField()->getSetting('default_image'); } if (!empty($default_image['fid']) && ($file = file_load($default_image['fid']))) { diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php index 162d887f32cb..b1e56f3f1250 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php @@ -147,7 +147,7 @@ public function settingsForm(array $form, array &$form_state, $has_data) { // We need the field-level 'default_image' setting, and $this->getSettings() // will only provide the instance-level one, so we need to explicitly fetch // the field. - $settings = $this->getFieldDefinition()->getField()->getFieldSettings(); + $settings = $this->getFieldDefinition()->getField()->getSettings(); $scheme_options = array(); foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) { diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldWidget/ImageWidget.php index 3a37aa0406c1..c3afdbb8d0e6 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldWidget/ImageWidget.php @@ -78,7 +78,7 @@ public function settingsSummary() { protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) { $elements = parent::formMultipleElements($items, $form, $form_state); - $cardinality = $this->fieldDefinition->getFieldCardinality(); + $cardinality = $this->fieldDefinition->getCardinality(); $file_upload_help = array( '#theme' => 'file_upload_help', '#upload_validators' => $elements[0]['#upload_validators'], @@ -87,7 +87,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f if ($cardinality == 1) { // If there's only one field, return it as delta 0. if (empty($elements[0]['#default_value']['fids'])) { - $file_upload_help['#description'] = field_filter_xss($this->fieldDefinition->getFieldDescription()); + $file_upload_help['#description'] = field_filter_xss($this->fieldDefinition->getDescription()); $elements[0]['#description'] = drupal_render($file_upload_help); } } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php index a616a4df70c2..da688856a225 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php @@ -62,21 +62,21 @@ public function testDefaultImages() { $instance = $this->createImageField($field_name, 'article', $field_settings, $instance_settings, $widget_settings); // The instance default image id should be 2. - $default_image = $instance->getFieldSetting('default_image'); + $default_image = $instance->getSetting('default_image'); $this->assertEqual($default_image['fid'], $default_images['instance']->id()); - // Also test \Drupal\field\Entity\FieldInstance::getFieldSetting(). - $instance_field_settings = $instance->getFieldSettings(); + // Also test \Drupal\field\Entity\FieldInstance::getSetting(). + $instance_field_settings = $instance->getSettings(); $this->assertEqual($instance_field_settings['default_image']['fid'], $default_images['instance']->id()); $field = $instance->getField(); // The field default image id should be 1. - $default_image = $field->getFieldSetting('default_image'); + $default_image = $field->getSetting('default_image'); $this->assertEqual($default_image['fid'], $default_images['field']->id()); - // Also test \Drupal\field\Entity\Field::getFieldSettings(). - $field_field_settings = $field->getFieldSettings(); + // Also test \Drupal\field\Entity\Field::getSettings(). + $field_field_settings = $field->getSettings(); $this->assertEqual($field_field_settings['default_image']['fid'], $default_images['field']->id()); // Add another instance with another default image to the page content type. diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php index 9ef216775c39..0071179c235e 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php @@ -252,7 +252,7 @@ function testImageFieldDefaultImage() { // Clear field info cache so the new default image is detected. field_info_cache_clear(); $field = field_info_field('node', $field_name); - $default_image = $field->getFieldSetting('default_image'); + $default_image = $field->getSetting('default_image'); $file = file_load($default_image['fid']); $this->assertTrue($file->isPermanent(), 'The default image status is permanent.'); $image = array( @@ -290,7 +290,7 @@ function testImageFieldDefaultImage() { // Clear field info cache so the new default image is detected. field_info_cache_clear(); $field = field_info_field('node', $field_name); - $default_image = $field->getFieldSetting('default_image'); + $default_image = $field->getSetting('default_image'); $this->assertFalse($default_image['fid'], 'Default image removed from field.'); // Create an image field that uses the private:// scheme and test that the // default image works as expected. @@ -307,7 +307,7 @@ function testImageFieldDefaultImage() { field_info_cache_clear(); $private_field = field_info_field('node', $private_field_name); - $default_image = $private_field->getFieldSetting('default_image'); + $default_image = $private_field->getSetting('default_image'); $file = file_load($default_image['fid']); $this->assertEqual('private', file_uri_scheme($file->getFileUri()), 'Default image uses private:// scheme.'); $this->assertTrue($file->isPermanent(), 'The default image status is permanent.'); diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldWidget/LinkWidget.php index 9c5e3cb431b8..dc105746435b 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldWidget/LinkWidget.php @@ -66,7 +66,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // If cardinality is 1, ensure a label is output for the field by wrapping it // in a details element. - if ($this->fieldDefinition->getFieldCardinality() == 1) { + if ($this->fieldDefinition->getCardinality() == 1) { $element += array( '#type' => 'fieldset', ); diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 41b7e89228a0..968184ac53f2 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -346,7 +346,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['type'] = FieldDefinition::create('entity_reference') ->setLabel(t('Type')) ->setDescription(t('The node type.')) - ->setFieldSetting('target_type', 'node_type') + ->setSetting('target_type', 'node_type') ->setReadOnly(TRUE); $fields['langcode'] = FieldDefinition::create('language') @@ -359,7 +359,7 @@ public static function baseFieldDefinitions($entity_type) { ->setClass('\Drupal\node\NodeTitleItemList') ->setRequired(TRUE) ->setTranslatable(TRUE) - ->setFieldSettings(array( + ->setSettings(array( 'default_value' => '', 'max_length' => 255, 'text_processing' => 0, @@ -368,7 +368,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['uid'] = FieldDefinition::create('entity_reference') ->setLabel(t('User ID')) ->setDescription(t('The user ID of the node author.')) - ->setFieldSettings(array( + ->setSettings(array( 'target_type' => 'user', 'default_value' => 0, )); @@ -400,13 +400,13 @@ public static function baseFieldDefinitions($entity_type) { $fields['revision_timestamp'] = FieldDefinition::create('integer') ->setLabel(t('Revision timestamp')) ->setDescription(t('The time that the current revision was created.')) - ->setFieldQueryable(FALSE); + ->setQueryable(FALSE); $fields['revision_uid'] = FieldDefinition::create('entity_reference') ->setLabel(t('Revision user ID')) ->setDescription(t('The user ID of the author of the current revision.')) - ->setFieldSettings(array('target_type' => 'user')) - ->setFieldQueryable(FALSE); + ->setSettings(array('target_type' => 'user')) + ->setQueryable(FALSE); $fields['log'] = FieldDefinition::create('string') ->setLabel(t('Log')) diff --git a/core/modules/node/lib/Drupal/node/NodeTitleItemList.php b/core/modules/node/lib/Drupal/node/NodeTitleItemList.php index c5f25e9002e8..2b811931ffb6 100644 --- a/core/modules/node/lib/Drupal/node/NodeTitleItemList.php +++ b/core/modules/node/lib/Drupal/node/NodeTitleItemList.php @@ -21,12 +21,12 @@ class NodeTitleItemList extends FieldItemList { * {@inheritdoc} * * The typehint for $definition is a class rather than an interface, because - * there is no interface for setFieldLabel(). + * there is no interface for setLabel(). */ public function __construct(FieldDefinition $definition, $name, NodeInterface $node) { $node_type = node_type_load($node->getType()); if (isset($node_type->title_label)) { - $definition->setFieldLabel($node_type->title_label); + $definition->setLabel($node_type->title_label); } parent::__construct($definition, $name, $node); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php index c7a352d1c34f..6cfc32f2334b 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php @@ -84,7 +84,7 @@ function testNodeTypeEditing() { $this->drupalLogin($web_user); $instance = field_info_instance('node', 'body', 'page'); - $this->assertEqual($instance->getFieldLabel(), 'Body', 'Body field was found.'); + $this->assertEqual($instance->getLabel(), 'Body', 'Body field was found.'); // Verify that title and body fields are displayed. $this->drupalGet('node/add/page'); diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 244a52b1b9f8..4037d5940d51 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -156,7 +156,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr $length = $settings['trim_length']; } - $output = text_summary($output, $instance->getFieldSetting('text_processing') ? $item->format : NULL, $length); + $output = text_summary($output, $instance->getSetting('text_processing') ? $item->format : NULL, $length); } } $replacements[$original] = $output; 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 896178388968..0f33b42f6f43 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 @@ -78,7 +78,7 @@ public function getConstraints() { $constraints = parent::getConstraints(); $settings = $this->getFieldSettings(); - $label = $this->getFieldDefinition()->getFieldLabel(); + $label = $this->getFieldDefinition()->getLabel(); if (!empty($settings['min'])) { $min = $settings['min']; diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldWidget/NumberWidget.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldWidget/NumberWidget.php index f252ccc169da..436e2cdc9fdb 100644 --- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldWidget/NumberWidget.php @@ -73,7 +73,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen ); // Set the step for floating point and decimal numbers. - switch ($this->fieldDefinition->getFieldType()) { + switch ($this->fieldDefinition->getType()) { case 'number_decimal': $element['#step'] = pow(0.1, $field_settings['scale']); break; diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OnOffWidget.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OnOffWidget.php index b0056d38c7ba..34b741ed3610 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OnOffWidget.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OnOffWidget.php @@ -68,7 +68,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Override the title from the incoming $element. if ($this->getSetting('display_label')) { - $element['#title'] = $this->fieldDefinition->getFieldLabel(); + $element['#title'] = $this->fieldDefinition->getLabel(); } else { $element['#title'] = isset($options[1]) ? $options[1] : ''; diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OptionsWidgetBase.php index baa30674feb6..b631837678df 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -47,7 +47,7 @@ abstract class OptionsWidgetBase extends WidgetBase { */ public function __construct($plugin_id, array $plugin_definition, FieldDefinitionInterface $field_definition, array $settings) { parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings); - $property_names = $this->fieldDefinition->getFieldPropertyNames(); + $property_names = $this->fieldDefinition->getPropertyNames(); $this->column = $property_names[0]; } @@ -58,7 +58,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Prepare some properties for the child methods to build the actual form // element. $this->required = $element['#required']; - $this->multiple = $this->fieldDefinition->isFieldMultiple(); + $this->multiple = $this->fieldDefinition->isMultiple(); $this->has_value = isset($items[0]->{$this->column}); // Add our custom validator. diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php index 3cd645bf7bf0..8793db2e10bd 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php @@ -232,9 +232,9 @@ function testOptionsAllowedValuesBoolean() { $this->assertFieldByName('on', $on, t("The 'On' value is stored correctly.")); $this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly.")); $field = field_info_field('node', $this->field_name); - $this->assertEqual($field->getFieldSetting('allowed_values'), $allowed_values, 'The allowed value is correct'); - $this->assertNull($field->getFieldSetting('on'), 'The on value is not saved into settings'); - $this->assertNull($field->getFieldSetting('off'), 'The off value is not saved into settings'); + $this->assertEqual($field->getSetting('allowed_values'), $allowed_values, 'The allowed value is correct'); + $this->assertNull($field->getSetting('on'), 'The on value is not saved into settings'); + $this->assertNull($field->getSetting('off'), 'The off value is not saved into settings'); } /** @@ -282,7 +282,7 @@ protected function createOptionsField($type) { * element. * @param $result * Either an expected resulting array in - * $field->getFieldSetting('allowed_values'), or an expected error message. + * $field->getSetting('allowed_values'), or an expected error message. * @param $message * Message to display. */ @@ -296,7 +296,7 @@ function assertAllowedValuesInput($input_string, $result, $message) { else { field_info_cache_clear(); $field = field_info_field('node', $this->field_name); - $this->assertIdentical($field->getFieldSetting('allowed_values'), $result, $message); + $this->assertIdentical($field->getSetting('allowed_values'), $result, $message); } } diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php index 1ecaba3667ac..02304b6b6e69 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php @@ -110,13 +110,13 @@ function setUp() { function testRadioButtons() { // Create an instance of the 'single value' field. $instance = entity_create('field_instance', array( - 'field_name' => $this->card_1->getFieldName(), + 'field_name' => $this->card_1->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', )); $instance->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_1->getFieldName(), array( + ->setComponent($this->card_1->getName(), array( 'type' => 'options_buttons', )) ->save(); @@ -167,13 +167,13 @@ function testRadioButtons() { function testCheckBoxes() { // Create an instance of the 'multiple values' field. $instance = entity_create('field_instance', array( - 'field_name' => $this->card_2->getFieldName(), + 'field_name' => $this->card_2->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', )); $instance->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_2->getFieldName(), array( + ->setComponent($this->card_2->getName(), array( 'type' => 'options_buttons', )) ->save(); @@ -257,14 +257,14 @@ function testCheckBoxes() { function testSelectListSingle() { // Create an instance of the 'single value' field. $instance = entity_create('field_instance', array( - 'field_name' => $this->card_1->getFieldName(), + 'field_name' => $this->card_1->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'required' => TRUE, )); $instance->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_1->getFieldName(), array( + ->setComponent($this->card_1->getName(), array( 'type' => 'options_select', )) ->save(); @@ -292,7 +292,7 @@ function testSelectListSingle() { // Submit form: select invalid 'none' option. $edit = array('card_1' => '_none'); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance->getFieldName())), 'Cannot save a required field when selecting "none" from the select list.'); + $this->assertRaw(t('!title field is required.', array('!title' => $instance->getName())), 'Cannot save a required field when selecting "none" from the select list.'); // Submit form: select first option. $edit = array('card_1' => 0); @@ -357,13 +357,13 @@ function testSelectListSingle() { function testSelectListMultiple() { // Create an instance of the 'multiple values' field. $instance = entity_create('field_instance', array( - 'field_name' => $this->card_2->getFieldName(), + 'field_name' => $this->card_2->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', )); $instance->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_2->getFieldName(), array( + ->setComponent($this->card_2->getName(), array( 'type' => 'options_select', )) ->save(); @@ -477,12 +477,12 @@ function testSelectListMultiple() { function testOnOffCheckbox() { // Create an instance of the 'boolean' field. entity_create('field_instance', array( - 'field_name' => $this->bool->getFieldName(), + 'field_name' => $this->bool->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->bool->getFieldName(), array( + ->setComponent($this->bool->getName(), array( 'type' => 'options_onoff', )) ->save(); diff --git a/core/modules/options/options.install b/core/modules/options/options.install index 40f49db81b39..f49447c90432 100644 --- a/core/modules/options/options.install +++ b/core/modules/options/options.install @@ -9,7 +9,7 @@ * Implements hook_field_schema(). */ function options_field_schema($field) { - switch ($field->getFieldType()) { + switch ($field->getType()) { case 'list_text': $columns = array( 'value' => array( diff --git a/core/modules/options/options.module b/core/modules/options/options.module index 05af8cea3e2b..44ce6b741a2c 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -68,8 +68,8 @@ function options_field_info() { * Implements hook_field_settings_form(). */ function options_field_settings_form($field, $instance) { - $settings = $field->getFieldSettings(); - $field_type = $field->getFieldType(); + $settings = $field->getSettings(); + $field_type = $field->getType(); switch ($field_type) { case 'list_integer': @@ -165,7 +165,7 @@ function options_field_settings_form($field, $instance) { function options_field_settings_form_validate_allowed_values($element, &$form_state) { $field = $element['#field']; $has_data = $element['#field_has_data']; - $field_type = $field->getFieldType(); + $field_type = $field->getType(); $generate_keys = ($field_type == 'list_integer' || $field_type == 'list_float') && !$has_data; $values = options_extract_allowed_values($element['#value'], $field_type, $generate_keys); @@ -192,7 +192,7 @@ function options_field_settings_form_validate_allowed_values($element, &$form_st // Prevent removing values currently in use. if ($has_data) { - $lost_keys = array_diff(array_keys($field->getFieldSetting('allowed_values')), array_keys($values)); + $lost_keys = array_diff(array_keys($field->getSetting('allowed_values')), array_keys($values)); if (_options_values_in_use($field, $lost_keys)) { form_error($element, $form_state, t('Allowed values list: some values are being removed while currently in use.')); } @@ -243,9 +243,9 @@ function options_field_entity_delete(FieldInterface $field) { function options_allowed_values(FieldDefinitionInterface $field_definition, EntityInterface $entity) { $allowed_values = &drupal_static(__FUNCTION__, array()); - $cache_id = implode(':', array($entity->entityType(), $entity->bundle(), $field_definition->getFieldName())); + $cache_id = implode(':', array($entity->entityType(), $entity->bundle(), $field_definition->getName())); if (!isset($allowed_values[$cache_id])) { - $function = $field_definition->getFieldSetting('allowed_values_function'); + $function = $field_definition->getSetting('allowed_values_function'); // If $cacheable is FALSE, then the allowed values are not statically // cached. See options_test_dynamic_values_callback() for an example of // generating dynamic and uncached values. @@ -254,7 +254,7 @@ function options_allowed_values(FieldDefinitionInterface $field_definition, Enti $values = $function($field_definition, $entity, $cacheable); } else { - $values = $field_definition->getFieldSetting('allowed_values'); + $values = $field_definition->getSetting('allowed_values'); } if ($cacheable) { @@ -368,11 +368,11 @@ function options_allowed_values_string($values) { function options_field_update_forbid($field, $prior_field) { if ($field->module == 'options' && $field->hasData()) { // Forbid any update that removes allowed values with actual data. - $allowed_values = $field->getFieldSetting('allowed_values'); - $prior_allowed_values = $prior_field->getFieldSetting('allowed_values'); + $allowed_values = $field->getSetting('allowed_values'); + $prior_allowed_values = $prior_field->getSetting('allowed_values'); $lost_keys = array_diff(array_keys($prior_allowed_values), array_keys($allowed_values)); if (_options_values_in_use($field, $lost_keys)) { - throw new FieldUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field->getFieldName()))); + throw new FieldUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field->getName()))); } } } @@ -384,7 +384,7 @@ function _options_values_in_use(FieldInterface $field, $values) { if ($values) { $factory = \Drupal::service('entity.query'); $result = $factory->get($field->entity_type) - ->condition($field->getFieldName() . '.value', $values) + ->condition($field->getName() . '.value', $values) ->count() ->accessCheck(FALSE) ->range(0, 1) @@ -417,9 +417,9 @@ function options_field_validate(EntityInterface $entity = NULL, $field, $instanc foreach ($items as $delta => $item) { if (!empty($item['value'])) { if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) { - $errors[$instance->getFieldName()][$langcode][$delta][] = array( + $errors[$instance->getName()][$langcode][$delta][] = array( 'error' => 'list_illegal_value', - 'message' => t('%name: illegal value.', array('%name' => $instance->getFieldLabel())), + 'message' => t('%name: illegal value.', array('%name' => $instance->getLabel())), ); } } diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index d4f7ec55b5a3..4f94f43cceb8 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -70,7 +70,7 @@ function setUp() { // Ensure configuration changes are picked up in the host environment. Field::fieldInfo()->flush(); $field = Field::fieldInfo()->getField('node', 'body'); - $this->assertTrue($field->isFieldTranslatable(), 'Node body is translatable.'); + $this->assertTrue($field->isTranslatable(), 'Node body is translatable.'); } /** diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 8414b72b82cf..c44b4fda0806 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -720,7 +720,7 @@ function hook_entity_operation_alter(array &$operations, \Drupal\Core\Entity\Ent * if the implementation has no opinion. */ function hook_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, \Drupal\Core\Session\AccountInterface $account, \Drupal\Core\Field\FieldItemListInterface $items = NULL) { - if ($field_definition->getFieldName() == 'field_of_interest' && $operation == 'edit') { + if ($field_definition->getName() == 'field_of_interest' && $operation == 'edit') { return user_access('update field of interest', $account); } } @@ -747,7 +747,7 @@ function hook_entity_field_access($operation, \Drupal\Core\Field\FieldDefinition */ function hook_entity_field_access_alter(array &$grants, array $context) { $field_definition = $context['field_definition']; - if ($field_definition->getFieldName() == 'field_of_interest' && $grants['node'] === FALSE) { + if ($field_definition->getName() == 'field_of_interest' && $grants['node'] === FALSE) { // Override node module's restriction to no opinion. We don't want to // provide our own access hook, we only want to take out node module's part // in the access handling of this field. We also don't want to switch node 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 77d150ecfafa..1e777a62d0ea 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -356,18 +356,18 @@ public function testIntrospection() { protected function checkIntrospection($entity_type) { // Test getting metadata upfront. $definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type); - $this->assertEqual($definitions['name']->getFieldType(), 'string', $entity_type .': Name field found.'); - $this->assertEqual($definitions['user_id']->getFieldType(), 'entity_reference', $entity_type .': User field found.'); - $this->assertEqual($definitions['field_test_text']->getFieldType(), 'text', $entity_type .': Test-text-field field found.'); + $this->assertEqual($definitions['name']->getType(), 'string', $entity_type .': Name field found.'); + $this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type .': User field found.'); + $this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type .': Test-text-field field found.'); // Test introspecting an entity object. // @todo: Add bundles and test bundles as well. $entity = entity_create($entity_type, array()); $definitions = $entity->getPropertyDefinitions(); - $this->assertEqual($definitions['name']->getFieldType(), 'string', $entity_type .': Name field found.'); - $this->assertEqual($definitions['user_id']->getFieldType(), 'entity_reference', $entity_type .': User field found.'); - $this->assertEqual($definitions['field_test_text']->getFieldType(), 'text', $entity_type .': Test-text-field field found.'); + $this->assertEqual($definitions['name']->getType(), 'string', $entity_type .': Name field found.'); + $this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type .': User field found.'); + $this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type .': Test-text-field field found.'); $name_properties = $entity->name->getPropertyDefinitions(); $this->assertEqual($name_properties['value']->getDataType(), 'string', $entity_type .': String value property of the name found.'); @@ -538,7 +538,7 @@ public function testEntityConstraintValidation() { // Create a reference field item and let it reference the entity. $definition = FieldDefinition::create('entity_reference') ->setLabel('Test entity') - ->setFieldSetting('target_type', 'entity_test'); + ->setSetting('target_type', 'entity_test'); $reference_field_item = \Drupal::TypedData()->create($definition); $reference = $reference_field_item->get('entity'); $reference->setValue($entity); @@ -561,7 +561,7 @@ public function testEntityConstraintValidation() { // Test bundle validation. $definition = FieldDefinition::create('entity_reference') ->setLabel('Test entity') - ->setFieldSettings(array( + ->setSettings(array( 'target_type' => 'node', 'target_bundle' => 'article', )); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php index cf38de6d670b..2e60246a4836 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php @@ -121,12 +121,12 @@ protected function toggleFieldTranslatability($entity_type) { $fields = array($this->field_name, $this->untranslatable_field_name); foreach ($fields as $field_name) { $field = FieldService::fieldInfo()->getField($entity_type, $field_name); - $translatable = !$field->isFieldTranslatable(); + $translatable = !$field->isTranslatable(); $field->set('translatable', $translatable); $field->save(); FieldService::fieldInfo()->flush(); $field = FieldService::fieldInfo()->getField($entity_type, $field_name); - $this->assertEqual($field->isFieldTranslatable(), $translatable, 'Field translatability changed.'); + $this->assertEqual($field->isTranslatable(), $translatable, 'Field translatability changed.'); } \Drupal::cache('field')->deleteAll(); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 7530db193de1..c7481629c12e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -106,7 +106,7 @@ function testEntityFormLanguage() { $field->translatable = TRUE; $field->save(); $field = field_info_field('node', 'body'); - $this->assertTrue($field->isFieldTranslatable(), 'Field body is translatable.'); + $this->assertTrue($field->isTranslatable(), 'Field body is translatable.'); // Create a body translation and check the form language. $langcode2 = $this->langcodes[1]; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index b8412356a5cd..1db4355cf307 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -515,17 +515,17 @@ function testFieldDefinitions() { $this->state->set('entity_test.field_definitions.translatable', array('name' => FALSE)); $this->entityManager->clearCachedFieldDefinitions(); $definitions = $this->entityManager->getFieldDefinitions($entity_type); - $this->assertFalse($definitions['name']->isFieldTranslatable(), 'Field translatability can be disabled programmatically.'); + $this->assertFalse($definitions['name']->isTranslatable(), 'Field translatability can be disabled programmatically.'); $this->state->set('entity_test.field_definitions.translatable', array('name' => TRUE)); $this->entityManager->clearCachedFieldDefinitions(); $definitions = $this->entityManager->getFieldDefinitions($entity_type); - $this->assertTrue($definitions['name']->isFieldTranslatable(), 'Field translatability can be enabled programmatically.'); + $this->assertTrue($definitions['name']->isTranslatable(), 'Field translatability can be enabled programmatically.'); // Check that field translatability is disabled by default. $base_field_definitions = EntityTestMulRev::baseFieldDefinitions($entity_type); $this->assertTrue(!isset($base_field_definitions['id']->translatable), 'Translatability for the <em>id</em> field is not defined.'); - $this->assertFalse($definitions['id']->isFieldTranslatable(), 'Field translatability is disabled by default.'); + $this->assertFalse($definitions['id']->isTranslatable(), 'Field translatability is disabled by default.'); // Check that entity ids and langcode fields cannot be translatable. foreach (array('id', 'uuid', 'revision_id', 'type', 'langcode') as $name) { diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 9c2b0b986b03..ede990771c4c 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -397,7 +397,7 @@ function entity_test_label_callback($entity_type, $entity, $langcode = NULL) { * @see \Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess() */ function entity_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) { - if ($field_definition->getFieldName() == 'field_test_text') { + if ($field_definition->getName() == 'field_test_text') { if ($items) { if ($items[0]->value == 'no access value') { return FALSE; @@ -415,7 +415,7 @@ function entity_test_entity_field_access($operation, FieldDefinitionInterface $f * @see \Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess() */ function entity_test_entity_field_access_alter(array &$grants, array $context) { - if ($context['field_definition']->getFieldName() == 'field_test_text' && $context['items'][0]->value == 'access alter value') { + if ($context['field_definition']->getName() == 'field_test_text' && $context['items'][0]->value == 'access alter value') { $grants[':default'] = FALSE; } } @@ -504,7 +504,7 @@ function entity_test_entity_test_mul_translation_delete(EntityInterface $transla * The field language code to fill-in with the default value. */ function entity_test_field_default_value(EntityInterface $entity, Field $field, FieldInstance $instance, $langcode) { - return array(array('value' => $field->getFieldName() . '_' . $langcode)); + return array(array('value' => $field->getName() . '_' . $langcode)); } /** diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php index 9b9ab57680dc..8ddc0089d1ee 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php @@ -144,7 +144,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['user_id'] = FieldDefinition::create('entity_reference') ->setLabel(t('User ID')) ->setDescription(t('The ID of the associated user.')) - ->setFieldSettings(array('target_type' => 'user')) + ->setSettings(array('target_type' => 'user')) ->setTranslatable(TRUE); return $fields; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php index 1c1251664bd3..9d7642494ebe 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php @@ -110,7 +110,7 @@ public function autocomplete(Request $request, $entity_type, $field_name) { $tags_typed = $request->query->get('q'); // Make sure the field exists and is a taxonomy field. - if (!($field = $this->fieldInfo->getField($entity_type, $field_name)) || $field->getFieldType() !== 'taxonomy_term_reference') { + if (!($field = $this->fieldInfo->getField($entity_type, $field_name)) || $field->getType() !== 'taxonomy_term_reference') { // Error string. The JavaScript handler will realize this is not JSON and // will display it as debugging information. return new Response(t('Taxonomy field @field_name not found.', array('@field_name' => $field_name)), 403); @@ -126,7 +126,7 @@ public function autocomplete(Request $request, $entity_type, $field_name) { // Part of the criteria for the query come from the field's own settings. $vids = array(); - foreach ($field->getFieldSetting('allowed_values') as $tree) { + foreach ($field->getSetting('allowed_values') as $tree) { $vids[] = $tree['vocabulary']; } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index 7e6c9e9c04e8..4fa499e6e2f6 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -227,18 +227,18 @@ public static function baseFieldDefinitions($entity_type) { $fields['description'] = FieldDefinition::create('text_long') ->setLabel(t('Description')) ->setDescription(t('A description of the term.')) - ->setFieldSetting('text_processing', 1); + ->setSetting('text_processing', 1); $fields['weight'] = FieldDefinition::create('integer') ->setLabel(t('Weight')) ->setDescription(t('The weight of this term in relation to other terms.')) - ->setFieldSetting('default_value', 0); + ->setSetting('default_value', 0); $fields['parent'] = FieldDefinition::create('integer') ->setLabel(t('Term Parents')) ->setDescription(t('The parents of this term.')) // Save new terms with no parents by default. - ->setFieldSetting('default_value', 0) + ->setSetting('default_value', 0) ->setComputed(TRUE); $fields['changed'] = FieldDefinition::create('integer') diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php index ec25ec1c9369..e25713896316 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php @@ -113,7 +113,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ $fields = field_read_fields(); foreach ($fields as $field) { $update_field = FALSE; - if ($field->getFieldType() == 'taxonomy_term_reference') { + if ($field->getType() == 'taxonomy_term_reference') { foreach ($field->settings['allowed_values'] as &$value) { if ($value['vocabulary'] == $this->getOriginalId()) { $value['vocabulary'] = $this->id(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php index 81bdefafce8a..0b3c2adeb017 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php @@ -74,7 +74,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#autocomplete_route_name' => $this->getSetting('autocomplete_route_name'), '#autocomplete_route_parameters' => array( 'entity_type' => $items->getEntity()->entityType(), - 'field_name' => $this->fieldDefinition->getFieldName(), + 'field_name' => $this->fieldDefinition->getName(), ), '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php index 080a1f6ef3c9..e7205dd4e9c8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php @@ -38,7 +38,7 @@ public function entityQueryAlter(SelectInterface $query) { */ public static function settingsForm(FieldDefinitionInterface $field_definition) { $form = parent::settingsForm($field_definition); - $selection_handler_settings = $field_definition->getFieldSetting('handler_settings'); + $selection_handler_settings = $field_definition->getSetting('handler_settings'); // @todo: Currently allow auto-create only on taxonomy terms. $form['auto_create'] = array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php index 8007b30e289b..60c466196154 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php @@ -126,7 +126,7 @@ function testTaxonomyTermFieldMultipleVocabularies() { // Verify that field and instance settings are correct. $field = field_info_field('entity_test', $this->field_name); - $this->assertEqual(count($field->getFieldSetting('allowed_values')), 1, 'Only one vocabulary is allowed for the field.'); + $this->assertEqual(count($field->getSetting('allowed_values')), 1, 'Only one vocabulary is allowed for the field.'); // The widget should still be displayed. $this->drupalGet('entity_test/add'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php index 34250d63bd0d..75ff53579f4b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -158,7 +158,7 @@ function testTaxonomyTermFieldChangeMachineName() { // Check that the field instance is still attached to the vocabulary. $field = field_info_field('entity_test', $this->field_name); - $allowed_values = $field->getFieldSetting('allowed_values'); + $allowed_values = $field->getSetting('allowed_values'); $this->assertEqual($allowed_values[0]['vocabulary'], $new_name, 'Index 0: Machine name was updated correctly.'); $this->assertEqual($allowed_values[1]['vocabulary'], $new_name, 'Index 1: Machine name was updated correctly.'); $this->assertEqual($allowed_values[2]['vocabulary'], 'foo', 'Index 2: Machine name was left untouched.'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 5aec19f9b1fd..410ff5ad5e16 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -114,7 +114,7 @@ function testTaxonomyNode() { $edit = array(); $edit['title[0][value]'] = $this->randomName(); $edit['body[0][value]'] = $this->randomName(); - $edit[$this->instance->getFieldName() . '[]'] = $term1->id(); + $edit[$this->instance->getName() . '[]'] = $term1->id(); $this->drupalPostForm('node/add/article', $edit, t('Save')); // Check that the term is displayed when the node is viewed. @@ -128,7 +128,7 @@ function testTaxonomyNode() { $this->assertText($term1->label(), 'Term is displayed after saving the node with no changes.'); // Edit the node with a different term. - $edit[$this->instance->getFieldName() . '[]'] = $term2->id(); + $edit[$this->instance->getName() . '[]'] = $term2->id(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->id()); @@ -148,7 +148,7 @@ function testNodeTermCreationAndDeletion() { // Enable tags in the vocabulary. $instance = $this->instance; entity_get_form_display($instance->entity_type, $instance->bundle, 'default') - ->setComponent($instance->getFieldName(), array( + ->setComponent($instance->getName(), array( 'type' => 'taxonomy_autocomplete', 'settings' => array( 'placeholder' => 'Start typing here.', @@ -167,7 +167,7 @@ function testNodeTermCreationAndDeletion() { $edit['body[0][value]'] = $this->randomName(); // Insert the terms in a comma separated list. Vocabulary 1 is a // free-tagging field created by the default profile. - $edit[$instance->getFieldName()] = drupal_implode_tags($terms); + $edit[$instance->getName()] = drupal_implode_tags($terms); // Verify the placeholder is there. $this->drupalGet('node/add/article'); @@ -523,7 +523,7 @@ function testReSavingTags() { // Enable tags in the vocabulary. $instance = $this->instance; entity_get_form_display($instance->entity_type, $instance->bundle, 'default') - ->setComponent($instance->getFieldName(), array( + ->setComponent($instance->getName(), array( 'type' => 'taxonomy_autocomplete', )) ->save(); @@ -533,7 +533,7 @@ function testReSavingTags() { $edit = array(); $edit['title[0][value]'] = $this->randomName(8); $edit['body[0][value]'] = $this->randomName(16); - $edit[$this->instance->getFieldName()] = $term->label(); + $edit[$this->instance->getName()] = $term->label(); $this->drupalPostForm('node/add/article', $edit, t('Save')); // Check that the term is displayed when editing and saving the node with no diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 1db21da833f0..4bc189fe2b3e 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -845,7 +845,7 @@ function taxonomy_field_widget_info_alter(&$info) { * Implements hook_options_list(). */ function taxonomy_options_list(FieldDefinitionInterface $field_definition, EntityInterface $entity) { - $function = $field_definition->getFieldSetting('options_list_callback') ?: 'taxonomy_allowed_values'; + $function = $field_definition->getSetting('options_list_callback') ?: 'taxonomy_allowed_values'; return $function($field_definition, $entity); } @@ -877,7 +877,7 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, FieldInterface $validate = TRUE; if (!empty($item['target_id']) && $item['target_id'] != 'autocreate') { $validate = FALSE; - foreach ($instance->getFieldSetting('allowed_values') as $settings) { + foreach ($instance->getSetting('allowed_values') as $settings) { // If no parent is specified, check if the term is in the vocabulary. if (isset($settings['vocabulary']) && empty($settings['parent'])) { if ($settings['vocabulary'] == $terms[$item['target_id']]->bundle()) { @@ -899,9 +899,9 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, FieldInterface } } if (!$validate) { - $errors[$instance->getFieldName()][$langcode][$delta][] = array( + $errors[$instance->getName()][$langcode][$delta][] = array( 'error' => 'taxonomy_term_reference_illegal_value', - 'message' => t('%name: illegal value.', array('%name' => $instance->getFieldLabel())), + 'message' => t('%name: illegal value.', array('%name' => $instance->getLabel())), ); } } @@ -928,7 +928,7 @@ function taxonomy_field_is_empty($item, $field_type) { */ function taxonomy_allowed_values(FieldDefinitionInterface $field_definition, EntityInterface $entity) { $options = array(); - foreach ($field_definition->getFieldSetting('allowed_values') as $tree) { + foreach ($field_definition->getSetting('allowed_values') as $tree) { if ($vocabulary = entity_load('taxonomy_vocabulary', $tree['vocabulary'])) { if ($terms = taxonomy_get_tree($vocabulary->id(), $tree['parent'], NULL, TRUE)) { foreach ($terms as $term) { @@ -980,7 +980,7 @@ function taxonomy_field_settings_form($field, $instance) { '#tree' => TRUE, ); - foreach ($field->getFieldSetting('allowed_values') as $delta => $tree) { + foreach ($field->getSetting('allowed_values') as $delta => $tree) { $form['allowed_values'][$delta]['vocabulary'] = array( '#type' => 'select', '#title' => t('Vocabulary'), @@ -1063,7 +1063,7 @@ function taxonomy_build_node_index($node) { $tid_all = array(); foreach (field_info_instances('node', $node->getType()) as $instance) { $field = $instance->getField(); - $field_name = $field->getFieldName(); + $field_name = $field->getName(); if ($field->module == 'taxonomy') { foreach ($node->getTranslationLanguages() as $language) { foreach ($node->getTranslation($language->id)->$field_name as $item) { diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 713d3243b836..4c4666bec638 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -410,13 +410,13 @@ function taxonomy_field_views_data(FieldInterface $field) { foreach ($table_data as $field_name => $field_data) { if (isset($field_data['filter']) && $field_name != 'delta') { $data[$table_name][$field_name]['filter']['id'] = 'taxonomy_index_tid'; - $allowed_values = $field->getFieldSetting('allowed_values'); + $allowed_values = $field->getSetting('allowed_values'); $data[$table_name][$field_name]['filter']['vocabulary'] = $allowed_values[0]['vocabulary']; } } // Add the relationship only on the tid field. - $field_name = $field->getFieldName(); + $field_name = $field->getName(); $data[$table_name][$field_name . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'taxonomy_term_data', @@ -435,7 +435,7 @@ function taxonomy_field_views_data(FieldInterface $field) { * Views integration to provide reverse relationships on term references. */ function taxonomy_field_views_data_views_data_alter(array &$data, FieldInterface $field) { - $field_name = $field->getFieldName(); + $field_name = $field->getName(); $entity_type = $field->entity_type; $entity_info = entity_get_info($entity_type); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type; 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 9efc5d416c33..8581bdf3a5a9 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 @@ -77,7 +77,7 @@ public function getConstraints() { 'value' => array( 'Length' => array( 'max' => $max_length, - 'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@max' => $max_length)), + 'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)), ) ), )); 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 5c3593ef46cf..cd783f9605c9 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 @@ -63,7 +63,7 @@ public function getConstraints() { 'value' => array( 'Length' => array( 'max' => $max_length, - 'maxMessage' => t('%name: the text may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@max' => $max_length)), + 'maxMessage' => t('%name: the text may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)), ) ), )); diff --git a/core/modules/text/lib/Drupal/text/TextProcessed.php b/core/modules/text/lib/Drupal/text/TextProcessed.php index e32087bd5c56..d07a1967d95d 100644 --- a/core/modules/text/lib/Drupal/text/TextProcessed.php +++ b/core/modules/text/lib/Drupal/text/TextProcessed.php @@ -52,7 +52,7 @@ public function getValue($langcode = NULL) { if (!isset($text) || $text === '') { $this->processed = ''; } - elseif ($item->getFieldDefinition()->getFieldSetting('text_processing')) { + elseif ($item->getFieldDefinition()->getSetting('text_processing')) { $this->processed = check_markup($text, $item->format, $item->getLangcode()); } else { diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index 660f59697f9c..30e43b430d80 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -455,7 +455,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['name'] = FieldDefinition::create('string') ->setLabel(t('Name')) ->setDescription(t('The name of this user.')) - ->setFieldSetting('default_value', '') + ->setSetting('default_value', '') ->setPropertyConstraints('value', array( // No Length constraint here because the UserName constraint also covers // that. @@ -470,7 +470,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['mail'] = FieldDefinition::create('email') ->setLabel(t('Email')) ->setDescription(t('The email of this user.')) - ->setFieldSetting('default_value', '') + ->setSetting('default_value', '') ->setPropertyConstraints('value', array('UserMailUnique' => array())); // @todo Convert to a text field in https://drupal.org/node/1548204. @@ -495,7 +495,7 @@ public static function baseFieldDefinitions($entity_type) { $fields['status'] = FieldDefinition::create('boolean') ->setLabel(t('User status')) ->setDescription(t('Whether the user is active (1) or blocked (0).')) - ->setFieldSetting('default_value', 1); + ->setSetting('default_value', 1); // @todo Convert to a "created" field in https://drupal.org/node/2145103. $fields['created'] = FieldDefinition::create('integer') @@ -506,18 +506,18 @@ public static function baseFieldDefinitions($entity_type) { $fields['access'] = FieldDefinition::create('integer') ->setLabel(t('Last access')) ->setDescription(t('The time that the user last accessed the site.')) - ->setFieldSetting('default_value', 0); + ->setSetting('default_value', 0); // @todo Convert to a "timestamp" field in https://drupal.org/node/2145103. $fields['login'] = FieldDefinition::create('integer') ->setLabel(t('Last login')) ->setDescription(t('The time that the user last logged in.')) - ->setFieldSetting('default_value', 0); + ->setSetting('default_value', 0); $fields['init'] = FieldDefinition::create('email') ->setLabel(t('Initial email')) ->setDescription(t('The email address used for initial account creation.')) - ->setFieldSetting('default_value', ''); + ->setSetting('default_value', ''); // @todo Convert this to entity_reference_field, see // https://drupal.org/node/2044859. diff --git a/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php b/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php index e921c1c4c1a0..2aeee7800c54 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php +++ b/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php @@ -31,7 +31,7 @@ class UserSelection extends SelectionBase { * {@inheritdoc} */ public static function settingsForm(FieldDefinitionInterface $field_definition) { - $selection_handler_settings = $field_definition->getFieldSetting('handler_settings'); + $selection_handler_settings = $field_definition->getSetting('handler_settings'); // Merge in default values. $selection_handler_settings += array( diff --git a/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php b/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php index 1fd8db800873..0b5d037f3d1e 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php +++ b/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php @@ -59,12 +59,12 @@ public function __construct(FieldDefinitionInterface $field_definition, EntityIn * {@inheritdoc} */ public static function settingsForm(FieldDefinitionInterface $field_definition) { - $selection_handler_settings = $field_definition->getFieldSetting('handler_settings') ?: array(); + $selection_handler_settings = $field_definition->getSetting('handler_settings') ?: array(); $view_settings = !empty($selection_handler_settings['view']) ? $selection_handler_settings['view'] : array(); $displays = views_get_applicable_views('entity_reference_display'); // Filter views that list the entity type we want, and group the separate // displays by view. - $entity_info = \Drupal::entityManager()->getDefinition($field_definition->getFieldSetting('target_type')); + $entity_info = \Drupal::entityManager()->getDefinition($field_definition->getSetting('target_type')); $options = array(); foreach ($displays as $data) { list($view, $display_id) = $data; @@ -131,14 +131,14 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) * Return TRUE if the view was initialized, FALSE otherwise. */ protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $limit = 0, $ids = NULL) { - $handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings'); + $handler_settings = $this->fieldDefinition->getSetting('handler_settings'); $view_name = $handler_settings['view']['view_name']; $display_name = $handler_settings['view']['display_name']; // Check that the view is valid and the display still exists. $this->view = views_get_view($view_name); if (!$this->view || !$this->view->access($display_name)) { - drupal_set_message(t('The reference view %view_name used in the %field_name field cannot be found.', array('%view_name' => $view_name, '%field_name' => $this->fieldDefinition->getFieldLabel())), 'warning'); + drupal_set_message(t('The reference view %view_name used in the %field_name field cannot be found.', array('%view_name' => $view_name, '%field_name' => $this->fieldDefinition->getLabel())), 'warning'); return FALSE; } $this->view->setDisplay($display_name); @@ -158,7 +158,7 @@ protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $ * {@inheritdoc} */ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { - $handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings'); + $handler_settings = $this->fieldDefinition->getSetting('handler_settings'); $display_name = $handler_settings['view']['display_name']; $arguments = $handler_settings['view']['arguments']; $result = array(); @@ -189,7 +189,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON * {@inheritdoc} */ public function validateReferenceableEntities(array $ids) { - $handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings'); + $handler_settings = $this->fieldDefinition->getSetting('handler_settings'); $display_name = $handler_settings['view']['display_name']; $arguments = $handler_settings['view']['arguments']; $result = array(); diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index f93725a471d0..2dd030a3366f 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -226,7 +226,7 @@ function views_ui_taxonomy_autocomplete_validate($element, &$form_state) { // vocabulary IDs. $field = field_info_field($element['#entity_type'], $element['#field_name']); $vocabularies = array(); - $allowed_values = $field->getFieldSetting('allowed_values'); + $allowed_values = $field->getSetting('allowed_values'); if (!empty($allowed_values)) { foreach ($allowed_values as $tree) { if ($vocabulary = entity_load('taxonomy_vocabulary', $tree['vocabulary'])) { diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php index 5dfc084b7735..2982685b40aa 100644 --- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php @@ -59,8 +59,8 @@ protected function setUp() { public function testFieldName() { $definition = new FieldDefinition(); $field_name = $this->randomName(); - $definition->setFieldName($field_name); - $this->assertEquals($field_name, $definition->getFieldName()); + $definition->setName($field_name); + $this->assertEquals($field_name, $definition->getName()); } /** @@ -69,8 +69,8 @@ public function testFieldName() { public function testFieldLabel() { $definition = new FieldDefinition(); $label = $this->randomName(); - $definition->setFieldLabel($label); - $this->assertEquals($label, $definition->getFieldLabel()); + $definition->setLabel($label); + $this->assertEquals($label, $definition->getLabel()); } /** @@ -79,8 +79,8 @@ public function testFieldLabel() { public function testFieldDescription() { $definition = new FieldDefinition(); $description = $this->randomName(); - $definition->setFieldDescription($description); - $this->assertEquals($description, $definition->getFieldDescription()); + $definition->setDescription($description); + $this->assertEquals($description, $definition->getDescription()); } /** @@ -89,7 +89,7 @@ public function testFieldDescription() { public function testFieldType() { $field_type = $this->randomName(); $definition = FieldDefinition::create($field_type); - $this->assertEquals($field_type, $definition->getFieldType()); + $this->assertEquals($field_type, $definition->getType()); } /** @@ -99,9 +99,9 @@ public function testFieldSettings() { $definition = new FieldDefinition(); $setting = $this->randomName(); $value = $this->randomName(); - $definition->setFieldSetting($setting, $value); - $this->assertEquals($value, $definition->getFieldSetting($setting)); - $this->assertEquals(array($setting => $value), $definition->getFieldSettings()); + $definition->setSetting($setting, $value); + $this->assertEquals($value, $definition->getSetting($setting)); + $this->assertEquals(array($setting => $value), $definition->getSettings()); } /** @@ -111,11 +111,11 @@ public function testFieldDefaultValue() { $definition = new FieldDefinition(); $setting = 'default_value'; $value = $this->randomName(); - $definition->setFieldSetting($setting, $value); + $definition->setSetting($setting, $value); $entity = $this->getMockBuilder('Drupal\Core\Entity\Entity') ->disableOriginalConstructor() ->getMock(); - $this->assertEquals($value, $definition->getFieldDefaultValue($entity)); + $this->assertEquals($value, $definition->getDefaultValue($entity)); } /** @@ -123,11 +123,11 @@ public function testFieldDefaultValue() { */ public function testFieldTranslatable() { $definition = new FieldDefinition(); - $this->assertFalse($definition->isFieldTranslatable()); + $this->assertFalse($definition->isTranslatable()); $definition->setTranslatable(TRUE); - $this->assertTrue($definition->isFieldTranslatable()); + $this->assertTrue($definition->isTranslatable()); $definition->setTranslatable(FALSE); - $this->assertFalse($definition->isFieldTranslatable()); + $this->assertFalse($definition->isTranslatable()); } /** @@ -135,7 +135,7 @@ public function testFieldTranslatable() { */ public function testFieldCardinality() { $definition = new FieldDefinition(); - $this->assertEquals(1, $definition->getFieldCardinality()); + $this->assertEquals(1, $definition->getCardinality()); // @todo: Add more tests when this can be controlled. } @@ -144,11 +144,11 @@ public function testFieldCardinality() { */ public function testFieldRequired() { $definition = new FieldDefinition(); - $this->assertFalse($definition->isFieldRequired()); - $definition->setFieldRequired(TRUE); - $this->assertTrue($definition->isFieldRequired()); - $definition->setFieldRequired(FALSE); - $this->assertFalse($definition->isFieldRequired()); + $this->assertFalse($definition->isRequired()); + $definition->setRequired(TRUE); + $this->assertTrue($definition->isRequired()); + $definition->setRequired(FALSE); + $this->assertFalse($definition->isRequired()); } /** @@ -156,7 +156,7 @@ public function testFieldRequired() { */ public function testFieldConfigurable() { $definition = new FieldDefinition(); - $this->assertFalse($definition->isFieldConfigurable()); + $this->assertFalse($definition->isConfigurable()); } } -- GitLab