diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
index b21958b..ebc328e 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
@@ -14,13 +14,12 @@
use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler;
use Drupal\Core\Entity\Sql\DefaultTableMapping;
use Drupal\Core\Entity\Sql\SqlEntityStorageInterface;
-use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\Language;
-use Drupal\field\FieldConfigUpdateForbiddenException;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldConfigInterface;
+use Drupal\field\FieldConfigUpdateForbiddenException;
use Drupal\field\FieldInstanceConfigInterface;
-use Drupal\field\Entity\FieldConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -236,11 +235,11 @@ protected function schemaHandler() {
public function getTableMapping() {
if (!isset($this->tableMapping)) {
- $definitions = array_filter($this->fieldStorageDefinitions, function (FieldDefinitionInterface $definition) {
+ $definitions = array_filter($this->fieldStorageDefinitions, function (FieldStorageDefinitionInterface $definition) {
// @todo Remove the check for FieldDefinitionInterface::isMultiple() when
// multiple-value base fields are supported in
// https://drupal.org/node/2248977.
- return !$definition->isComputed() && !$definition->hasCustomStorage() && !$definition->isMultiple();
+ return !$definition->hasCustomStorage() && !$definition->isMultiple();
});
$this->tableMapping = new DefaultTableMapping($definitions);
@@ -951,8 +950,10 @@ protected function doLoadFieldItems($entities, $age) {
// Collect impacted fields.
$fields = array();
+ $definitions = array();
foreach ($bundles as $bundle => $v) {
- foreach ($this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle) as $field_name => $instance) {
+ $definitions[$bundle] = $this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle);
+ foreach ($definitions[$bundle] as $field_name => $instance) {
if ($instance instanceof FieldInstanceConfigInterface) {
$fields[$field_name] = $instance->getField();
}
@@ -977,10 +978,11 @@ protected function doLoadFieldItems($entities, $age) {
$delta_count = array();
foreach ($results as $row) {
+ $bundle = $entities[$row->entity_id]->bundle();
// Ensure that records for non-translatable fields having invalid
// languages are skipped.
- if ($row->langcode == $default_langcodes[$row->entity_id] || $field->isTranslatable()) {
+ if ($row->langcode == $default_langcodes[$row->entity_id] || $definitions[$bundle][$field_name]->isTranslatable()) {
if (!isset($delta_count[$row->entity_id][$row->langcode])) {
$delta_count[$row->entity_id][$row->langcode] = 0;
}
diff --git a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php
index 5e7c0e5..207cb4c 100644
--- a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php
+++ b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php
@@ -84,8 +84,10 @@ public function getSchema() {
foreach ($table_mapping->getTableNames() as $table_name) {
// Add the schema from field definitions.
foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
- $column_names = $table_mapping->getColumnNames($field_name);
- $this->addFieldSchema($schema[$table_name], $field_name, $column_names);
+ if (isset($this->fieldStorageDefinitions[$field_name])) {
+ $column_names = $table_mapping->getColumnNames($field_name);
+ $this->addFieldSchema($schema[$table_name], $field_name, $column_names);
+ }
}
// Add the schema for extra fields.
diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php
index cfeccf8..ecd7389 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinition.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinition.php
@@ -15,7 +15,7 @@
/**
* A class for defining entity fields.
*/
-class FieldDefinition extends ListDataDefinition implements FieldDefinitionInterface {
+class FieldDefinition extends ListDataDefinition implements FieldDefinitionInterface, FieldStorageDefinitionInterface {
/**
* The field type.
@@ -253,7 +253,7 @@ public function getCardinality() {
* Sets the maximum number of items allowed for the field.
*
* Possible values are positive integers or
- * FieldDefinitionInterface::CARDINALITY_UNLIMITED.
+ * FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED.
*
* @param int $cardinality
* The field cardinality.
diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
index a6c9190..e479d8e 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
@@ -52,7 +52,7 @@
* based on that abstract definition, even though that abstract definition can
* differ from the concrete definition of any particular node's body field.
*/
-interface FieldDefinitionInterface extends FieldStorageDefinitionInterface, ListDataDefinitionInterface {
+interface FieldDefinitionInterface extends ListDataDefinitionInterface {
/**
* Returns whether the display for the field can be configured.
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index 39be1ee..b49dbe0 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -7,11 +7,11 @@
namespace Drupal\Core\Field;
+use Drupal\Core\Language\Language;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\DataDefinitionInterface;
-use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\TypedData\Plugin\DataType\ItemList;
-use Drupal\Core\Language\Language;
+use Drupal\Core\TypedData\TypedDataInterface;
/**
* Represents an entity field; that is, a list of field item objects.
@@ -295,7 +295,7 @@ public function getConstraints() {
// form submitted values, this can only happen with 'multiple value'
// widgets.
$cardinality = $this->getFieldDefinition()->getCardinality();
- if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
+ if ($cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$constraints[] = \Drupal::typedDataManager()
->getValidationConstraintManager()
->create('Count', array(
diff --git a/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php
index 6dc9808..5a40e86 100644
--- a/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php
@@ -85,6 +85,16 @@ public function getSetting($setting_name);
public function isTranslatable();
/**
+ * Sets whether the field is translatable.
+ *
+ * @param bool $translatable
+ * Whether the field is translatable.
+ *
+ * @return $this
+ */
+ public function setTranslatable($translatable);
+
+ /**
* Returns whether the field is revisionable.
*
* @return bool
@@ -193,8 +203,8 @@ public function getMainPropertyName();
* This method should not be confused with EntityInterface::entityType()
* (configurable fields are config entities, and thus implement both
* interfaces):
- * - FieldDefinitionInterface::getTargetEntityTypeId() answers "as a field,
- * which entity type are you attached to?".
+ * - FieldStorageDefinitionInterface::getTargetEntityTypeId() answers "as a
+ * field, which entity type are you attached to?".
* - EntityInterface::getEntityTypeId() answers "as a (config) entity, what
* is your own entity type".
*
@@ -231,7 +241,7 @@ public function getSchema();
* The array of field columns, keyed by column name, in the same format
* returned by getSchema().
*
- * @see \Drupal\Core\Field\FieldDefinitionInterface::getSchema()
+ * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSchema()
*/
public function getColumns();
diff --git a/core/lib/Drupal/Core/Field/StorableFieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/StorableFieldDefinitionInterface.php
new file mode 100644
index 0000000..2594871
--- /dev/null
+++ b/core/lib/Drupal/Core/Field/StorableFieldDefinitionInterface.php
@@ -0,0 +1,22 @@
+setLabel(t('Comment field name'))
->setDescription(t('The field name through which this comment was added.'))
- ->setComputed(TRUE);
+ ->setComputed(TRUE)
+ ->setCustomStorage(TRUE);
$item_definition = $fields['field_name']->getItemDefinition();
$item_definition->setClass('\Drupal\comment\CommentFieldNameItem');
diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc
index eb03aea..3552b7b 100644
--- a/core/modules/content_translation/content_translation.admin.inc
+++ b/core/modules/content_translation/content_translation.admin.inc
@@ -7,9 +7,9 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\StorableFieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Render\Element;
-use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldInstanceConfigInterface;
/**
@@ -79,7 +79,17 @@ function _content_translation_form_language_content_settings_form_alter(array &$
$dependent_options_settings = array();
$entity_manager = Drupal::entityManager();
foreach ($form['#labels'] as $entity_type_id => $label) {
- $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
+ $entity_type = $entity_manager->getDefinition($entity_type_id);
+
+ // @todo Remove the try/catch block as soon as also Menu Links are converted
+ // to the Entity Field API. See https://drupal.org/node/2256521.
+ try {
+ $storage_definitions = $entity_manager->getFieldStorageDefinitions($entity_type_id);
+ }
+ catch (\LogicException $e) {
+ $storage_definitions = array();
+ }
+
foreach (entity_get_bundles($entity_type_id) as $bundle => $bundle_info) {
// Here we do not want the widget to be altered and hold also the "Enable
// translation" checkbox, which would be redundant. Hence we add this key
@@ -98,44 +108,34 @@ function _content_translation_form_language_content_settings_form_alter(array &$
$field_settings = content_translation_get_config($entity_type_id, $bundle, 'fields');
foreach ($fields as $field_name => $definition) {
- $translatable = !empty($field_settings[$field_name]);
-
- // We special case Field API fields as they always natively support
- // translation.
- // @todo Remove this special casing as soon as configurable and
- // base field definitions are "unified".
- if ($definition instanceof FieldInstanceConfigInterface) {
+ // Allow to configure only fields supporting multilingual storage.
+ if (!empty($storage_definitions[$field_name]) && $storage_definitions[$field_name]->isTranslatable()) {
+ $translatable = $definition instanceof StorableFieldDefinitionInterface ? $definition->isTranslatable() : !empty($field_settings[$field_name]);
+ // If we have a storable field definition we use the stored value
+ // instead of our settings to determine translatability.
$form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = array(
'#label' => $definition->getLabel(),
'#type' => 'checkbox',
'#default_value' => $translatable,
);
- $column_element = content_translation_field_sync_widget($definition);
- if ($column_element) {
- $form['settings'][$entity_type_id][$bundle]['columns'][$field_name] = $column_element;
-
- // @todo This should not concern only files.
- if (isset($column_element['#options']['file'])) {
- $dependent_options_settings["settings[{$entity_type_id}][{$bundle}][columns][{$field_name}]"] = array('file');
+ // Display the column translatability configuration widget.
+ if ($definition instanceof FieldInstanceConfigInterface) {
+ $column_element = content_translation_field_sync_widget($definition);
+ if ($column_element) {
+ $form['settings'][$entity_type_id][$bundle]['columns'][$field_name] = $column_element;
+ // @todo This should not concern only files.
+ if (isset($column_element['#options']['file'])) {
+ $dependent_options_settings["settings[{$entity_type_id}][{$bundle}][columns][{$field_name}]"] = array('file');
+ }
}
}
}
- // Instead we need to rely on field definitions to determine whether
- // 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->isTranslatable()) {
- $form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = array(
- '#label' => $definition->getLabel(),
- '#type' => 'checkbox',
- '#default_value' => $translatable,
- );
- }
}
}
}
}
}
+
$settings = array('dependent_selectors' => $dependent_options_settings);
$form['#attached']['js'][] = array('data' => array('contentTranslationDependentOptions' => $settings), 'type' => 'setting');
$form['#validate'][] = 'content_translation_form_language_content_settings_validate';
@@ -300,68 +300,38 @@ function content_translation_form_language_content_settings_submit(array $form,
// If an entity type is not translatable all its bundles and fields must be
// marked as non-translatable. Similarly, if a bundle is made non-translatable
// all of its fields will be not translatable.
- foreach ($settings as $entity_type => &$entity_settings) {
- foreach ($entity_settings as &$bundle_settings) {
+ foreach ($settings as $entity_type_id => &$entity_settings) {
+ foreach ($entity_settings as $bundle => &$bundle_settings) {
if (!empty($bundle_settings['translatable'])) {
- $bundle_settings['translatable'] = $bundle_settings['translatable'] && $entity_types[$entity_type];
+ $bundle_settings['translatable'] = $bundle_settings['translatable'] && $entity_types[$entity_type_id];
}
if (!empty($bundle_settings['fields'])) {
+ $definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type_id, $bundle);
foreach ($bundle_settings['fields'] as $field_name => $translatable) {
- $bundle_settings['fields'][$field_name] = $translatable && $bundle_settings['translatable'];
+ $translatable = $translatable && $bundle_settings['translatable'];
// If we have column settings and no column is translatable, no point
// in making the field translatable.
if (isset($bundle_settings['columns'][$field_name]) && !array_filter($bundle_settings['columns'][$field_name])) {
- $bundle_settings['fields'][$field_name] = FALSE;
+ $translatable = FALSE;
}
- }
- }
- }
- }
-
- _content_translation_update_field_translatability($settings);
- drupal_set_message(t('Settings successfully updated.'));
-}
-
-/**
- * Stores content translation settings.
- *
- * @param array $settings
- * An associative array of settings keyed by entity type and bundle. At bundle
- * level the following keys are available:
- * - translatable: The bundle translatability status, which is a bool.
- * - settings: An array of language configuration settings as defined by
- * language_save_default_configuration().
- * - fields: An associative array with field names as keys and a boolean as
- * value, indicating field translatability.
- */
-function _content_translation_update_field_translatability($settings) {
- // Update translatability for configurable fields.
- // @todo Remove this once configurable fields rely on entity field info to
- // track translatability. See https://drupal.org/node/2018685.
- foreach ($settings as $entity_type => $entity_settings) {
- $fields = array();
- foreach ($entity_settings as $bundle_settings) {
- // Collapse field settings since here we have per instance settings, but
- // translatability has per-field scope. We assume that all the field
- // instances have the same value.
- if (!empty($bundle_settings['fields'])) {
- foreach ($bundle_settings['fields'] as $field_name => $translatable) {
- // If translatability changes for at least one field instance we need
- // to switch field translatability.
- $field = FieldConfig::loadByName($entity_type, $field_name);
- if ($field && $field->isTranslatable() !== $translatable) {
- $fields[$field_name] = $translatable;
+ // If we have a storable field definition we directly persist any
+ // change to translatability, otherwise we store changes in our config
+ // so we can properly alter field definitions later.
+ $definition = $definitions[$field_name];
+ if ($definition instanceof StorableFieldDefinitionInterface) {
+ if ($definition->isTranslatable() != $translatable) {
+ $definition->setTranslatable($translatable);
+ $definition->save();
+ }
+ }
+ else {
+ $bundle_settings['fields'][$field_name] = $translatable;
}
}
}
}
- // Store updated fields.
- foreach ($fields as $field_name => $translatable) {
- $field = FieldConfig::loadByName($entity_type, $field_name);
- $field->translatable = $translatable;
- $field->save();
- }
}
content_translation_save_settings($settings);
+ drupal_set_message(t('Settings successfully updated.'));
}
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index db3ae7a..1e29b37 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -5,15 +5,12 @@
* Allows entities to be translated into different languages.
*/
-use Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\Field\FieldDefinition;
+use Drupal\Core\Field\StorableFieldDefinitionInterface;
use Drupal\Core\Language\Language;
-use Drupal\Core\Session\AccountInterface;
-use Drupal\Core\TypedData\TranslatableInterface;
use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\node\NodeInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -145,22 +142,21 @@ function content_translation_entity_bundle_info_alter(&$bundles) {
}
/**
- * Implements hook_entity_base_field_info_alter().
+ * Implements hook_entity_bundle_field_info_alter().
*/
-function content_translation_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
- $translation_settings = \Drupal::config('content_translation.settings')->get($entity_type->id());
-
- if ($translation_settings) {
- // Currently field translatability is defined per-field but we may want to
- // make it per-instance instead. In that case, we will need to implement
- // hook_bundle_field_info_alter() instead.
- $field_settings = array();
- foreach ($translation_settings as $bundle => $settings) {
- $field_settings += !empty($settings['content_translation']['fields']) ? $settings['content_translation']['fields'] : array();
- }
-
- foreach ($field_settings as $name => $translatable) {
- if (isset($fields[$name]) && $fields[$name] instanceof FieldDefinition) {
+function content_translation_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) {
+ $settings = content_translation_get_config($entity_type->id(), $bundle, 'fields');
+ if (!empty($settings)) {
+ // @todo $base_field_definitions should probably passed also to the alter
+ // hook.
+ $base_field_definitions = \Drupal::entityManager()->getBaseFieldDefinitions($entity_type->id());
+ foreach ($settings as $name => $translatable) {
+ // Skip storable field definitions as those are supposed to have already
+ // been changed.
+ if (isset($base_field_definitions[$name]) && !$base_field_definitions[$name] instanceof StorableFieldDefinitionInterface) {
+ if (!isset($fields[$name])) {
+ $fields[$name] = clone $base_field_definitions[$name];
+ }
$fields[$name]->setTranslatable((bool) $translatable);
}
}
@@ -638,56 +634,35 @@ function content_translation_entity_extra_field_info() {
/**
* Implements hook_form_FORM_ID_alter() for 'field_ui_field_edit_form'.
*/
-function content_translation_form_field_ui_field_edit_form_alter(array &$form, array &$form_state, $form_id) {
- $field = $form['#field'];
- $bundle = $form['#bundle'];
- $bundle_is_translatable = content_translation_enabled($field->entity_type, $bundle);
- $form['field']['translatable'] = array(
+function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state) {
+ $instance = $form_state['instance'];
+ $bundle_is_translatable = content_translation_enabled($instance->entity_type, $instance->bundle);
+
+ $form['instance']['translatable'] = array(
'#type' => 'checkbox',
'#title' => t('Users may translate this field.'),
- '#default_value' => $field->isTranslatable(),
- '#weight' => 20,
+ '#default_value' => $instance->isTranslatable(),
+ '#weight' => -1,
'#disabled' => !$bundle_is_translatable,
+ '#access' => $instance->getField()->isTranslatable(),
);
- $form['#submit'][] = 'content_translation_form_field_ui_field_edit_form_submit';
// Provide helpful pointers for administrators.
if (\Drupal::currentUser()->hasPermission('administer content translation') && !$bundle_is_translatable) {
$toggle_url = url('admin/config/regional/content-language', array(
'query' => drupal_get_destination(),
));
- $form['field']['translatable']['#description'] = t('To enable translation of this field, enable language support for this type.', array(
+ $form['instance']['translatable']['#description'] = t('To configure translation for this field, enable language support for this type.', array(
'@language-settings-url' => $toggle_url,
));
}
-}
-
-/**
- * Form submission handler for 'field_ui_field_edit_form'.
- */
-function content_translation_form_field_ui_field_edit_form_submit($form, array &$form_state) {
- $instance = $form_state['instance'];
- $value = content_translation_get_config($instance->entity_type, $instance->bundle, 'fields');
- if (!isset($value)) {
- $value = array();
- }
- $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) {
- content_translation_set_config($instance->entity_type, $bundle, 'fields', $value);
- }
-}
-/**
- * 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_state['instance']->isTranslatable()) {
+ if ($instance->isTranslatable()) {
module_load_include('inc', 'content_translation', 'content_translation.admin');
- $element = content_translation_field_sync_widget($form_state['instance']);
+ $element = content_translation_field_sync_widget($instance);
if ($element) {
$form['instance']['settings']['translation_sync'] = $element;
+ $form['instance']['settings']['translation_sync']['#weight'] = -10;
}
}
}
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
index 5220da7..59c82db 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
@@ -8,7 +8,7 @@
namespace Drupal\content_translation\Tests;
use Drupal\Core\Language\Language;
-use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\simpletest\WebTestBase;
/**
@@ -21,7 +21,7 @@ class ContentTranslationSettingsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'node', 'comment', 'field_ui');
+ public static $modules = array('language', 'content_translation', 'node', 'comment', 'field_ui', 'entity_test');
public static function getInfo() {
return array(
@@ -39,6 +39,7 @@ function setUp() {
$this->drupalCreateContentType(array('type' => 'article'));
$this->drupalCreateContentType(array('type' => 'page'));
$this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment_article');
+ $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment_page');
$admin_user = $this->drupalCreateUser(array('access administration pages', 'administer languages', 'administer content translation', 'administer content types', 'administer node fields', 'administer comment fields'));
$this->drupalLogin($admin_user);
@@ -94,8 +95,18 @@ function testSettingsUI() {
'settings[comment][node__comment_article][fields][comment_body]' => TRUE,
);
$this->assertSettings('comment', 'node__comment_article', TRUE, $edit);
- $field = FieldConfig::loadByName('comment', 'comment_body');
- $this->assertTrue($field->isTranslatable(), 'Comment body is translatable.');
+ $definition = $this->entityManager()->getFieldDefinitions('comment', 'node__comment_article')['comment_body'];
+ $this->assertTrue($definition->isTranslatable(), 'Article comment body is translatable.');
+ $definition = $this->entityManager()->getFieldDefinitions('comment', 'node__comment_page')['comment_body'];
+ $this->assertFalse($definition->isTranslatable(), 'Page comment body is not translatable.');
+
+ // Test that translation can be enabled for base fields.
+ $edit = array(
+ 'entity_types[entity_test_mul]' => TRUE,
+ 'settings[entity_test_mul][entity_test_mul][translatable]' => TRUE,
+ 'settings[entity_test_mul][entity_test_mul][fields][name]' => TRUE,
+ );
+ $this->assertSettings('entity_test_mul', 'entity_test_mul', TRUE, $edit);
// Test that language settings are correctly stored.
$language_configuration = language_get_default_configuration('comment', 'node__comment_article');
@@ -103,9 +114,9 @@ function testSettingsUI() {
$this->assertTrue($language_configuration['language_show'], 'The language selector for article comments is shown.');
// Verify language widget appears on node type form.
- $this->drupalGet('admin/structure/comments/manage/node__comment_article/fields/comment.node__comment_article.comment_body/field');
- $this->assertField('field[translatable]');
- $this->assertFieldChecked('edit-field-translatable');
+ $this->drupalGet('admin/structure/comments/manage/node__comment_article/fields/comment.node__comment_article.comment_body');
+ $this->assertField('instance[translatable]');
+ $this->assertFieldChecked('edit-instance-translatable');
// Verify that translation may be enabled for the article content type.
$edit = array(
@@ -133,20 +144,20 @@ function testSettingsUI() {
// Test that configurable field translatability is correctly switched.
$edit = array('settings[node][article][fields][body]' => $translatable);
$this->assertSettings('node', 'article', TRUE, $edit);
- $field = FieldConfig::loadByName('node', 'body');
+ $instance = FieldInstanceConfig::loadByName('node', 'article', 'body');
$definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article');
$this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.');
- $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
+ $this->assertEqual($instance->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
// Test that also the Field UI form behaves correctly.
$translatable = !$translatable;
- $edit = array('field[translatable]' => $translatable);
- $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body/field', $edit, t('Save field settings'));
+ $edit = array('instance[translatable]' => $translatable);
+ $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body', $edit, t('Save settings'));
\Drupal::entityManager()->clearCachedFieldDefinitions();
- $field = FieldConfig::loadByName('node', 'body');
+ $instance = FieldInstanceConfig::loadByName('node', 'article', 'body');
$definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article');
$this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.');
- $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
+ $this->assertEqual($instance->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
}
}
@@ -195,9 +206,9 @@ function testFieldTranslatableSettingsUI() {
// Tests that field instance doesn't have translatable setting if bundle
// is not translatable.
- $path = 'admin/structure/types/manage/article/fields/node.article.body/field';
+ $path = 'admin/structure/types/manage/article/fields/node.article.body';
$this->drupalGet($path);
- $this->assertText('To enable translation of this field, enable language support for this type.', 'No translatable setting for field.');
+ $this->assertText('To configure translation for this field, enable language support for this type.', 'No translatable setting for field.');
// Tests that field instance has translatable setting if bundle is
// translatable. Note: this field instance is not translatable when
@@ -213,4 +224,14 @@ function testFieldTranslatableSettingsUI() {
$this->assertNoText('To enable translation of this field, enable language support for this type.', 'No translatable setting for field.');
}
+ /**
+ * Returns the entity manager.
+ *
+ * @return \Drupal\Core\Entity\EntityManagerInterface
+ * The entity manager;
+ */
+ protected function entityManager() {
+ return $this->container->get('entity.manager');
+ }
+
}
diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php
index cc883c8..61e3308 100644
--- a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php
+++ b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php
@@ -7,8 +7,7 @@
namespace Drupal\entity_reference\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Language\Language;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
@@ -45,7 +44,7 @@ function setUp() {
'target_type' => 'node',
),
'type' => 'entity_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance_config', array(
diff --git a/core/modules/field/config/schema/field.schema.yml b/core/modules/field/config/schema/field.schema.yml
index 7d3c209..48504a4 100644
--- a/core/modules/field/config/schema/field.schema.yml
+++ b/core/modules/field/config/schema/field.schema.yml
@@ -67,6 +67,9 @@ field.instance.*.*.*:
required:
type: boolean
label: 'Required field'
+ translatable:
+ type: boolean
+ label: 'Translatable'
default_value:
type: field.[%parent.field_type].value
default_value_function:
diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php
index 3f5b787..6e16ab7 100644
--- a/core/modules/field/src/Entity/FieldConfig.php
+++ b/core/modules/field/src/Entity/FieldConfig.php
@@ -110,11 +110,11 @@ class FieldConfig extends ConfigEntityBase implements FieldConfigInterface {
/**
* Flag indicating whether the field is translatable.
*
- * Defaults to FALSE.
+ * Defaults to TRUE.
*
* @var bool
*/
- public $translatable = FALSE;
+ public $translatable = TRUE;
/**
* Flag indicating whether the field is available for editing.
@@ -569,12 +569,7 @@ public function isRevisionable() {
}
/**
- * Sets whether the field is translatable.
- *
- * @param bool $translatable
- * Whether the field is translatable.
- *
- * @return $this
+ * {@inheritdoc}
*/
public function setTranslatable($translatable) {
$this->translatable = $translatable;
diff --git a/core/modules/field/src/Entity/FieldInstanceConfig.php b/core/modules/field/src/Entity/FieldInstanceConfig.php
index 0292ec9..e7624a7 100644
--- a/core/modules/field/src/Entity/FieldInstanceConfig.php
+++ b/core/modules/field/src/Entity/FieldInstanceConfig.php
@@ -121,6 +121,15 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
public $required = FALSE;
/**
+ * Flag indicating whether the field is translatable.
+ *
+ * Defaults to TRUE.
+ *
+ * @var bool
+ */
+ public $translatable = TRUE;
+
+ /**
* Default field value.
*
* The default value is used when an entity is created, either:
@@ -274,6 +283,7 @@ public function toArray() {
'label',
'description',
'required',
+ 'translatable',
'default_value',
'default_value_function',
'settings',
@@ -545,7 +555,16 @@ public function getProvider() {
* {@inheritdoc}
*/
public function isTranslatable() {
- return $this->getField()->translatable;
+ // A field can be enabled for translation only if translation is supported.
+ return $this->translatable && $this->getField()->isTranslatable();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setTranslatable($translatable) {
+ $this->translatable = $translatable;
+ return $this;
}
/**
diff --git a/core/modules/field/src/FieldInstanceConfigInterface.php b/core/modules/field/src/FieldInstanceConfigInterface.php
index 6c84282..ad4e23c 100644
--- a/core/modules/field/src/FieldInstanceConfigInterface.php
+++ b/core/modules/field/src/FieldInstanceConfigInterface.php
@@ -8,12 +8,12 @@
namespace Drupal\field;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\StorableFieldDefinitionInterface;
/**
* Provides an interface defining a field instance entity.
*/
-interface FieldInstanceConfigInterface extends ConfigEntityInterface, FieldDefinitionInterface {
+interface FieldInstanceConfigInterface extends ConfigEntityInterface, StorableFieldDefinitionInterface {
/**
* Returns the field entity for this instance.
diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php
index ec794fd..9f26108 100644
--- a/core/modules/field/src/Plugin/views/field/Field.php
+++ b/core/modules/field/src/Plugin/views/field/Field.php
@@ -8,21 +8,21 @@
namespace Drupal\field\Plugin\views\field;
use Drupal\Component\Utility\Xss;
+use Drupal\Core\Entity\ContentEntityDatabaseStorage;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
-use Drupal\Core\Field\FieldDefinition;
use Drupal\Core\Entity\EntityStorageInterface;
-use Drupal\Core\Render\Element;
-use Drupal\Core\Entity\ContentEntityDatabaseStorage;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldDefinition;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\FormatterPluginManager;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
+use Drupal\Core\Render\Element;
use Drupal\Core\Session\AccountInterface;
-use Drupal\views\Views;
-use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
+use Drupal\views\ViewExecutable;
+use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -532,7 +532,7 @@ function multiple_options_form(&$form, &$form_state) {
// translating prefix and suffix separately.
list($prefix, $suffix) = explode('@count', t('Display @count value(s)'));
- if ($field->getCardinality() == FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
+ if ($field->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$type = 'textfield';
$options = NULL;
$size = 5;
@@ -902,8 +902,8 @@ function field_langcode(EntityInterface $entity) {
$default_langcode = language_default()->id;
$langcode = str_replace(
array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
- array($this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT), $default_langcode),
- $this->view->display_handler->options['field_language']
+ array($this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT)->id, $default_langcode),
+ $this->view->display_handler->options['field_langcode']
);
// Give the Entity Field API a chance to fallback to a different language
diff --git a/core/modules/field/src/Tests/ConfigFieldDefinitionTest.php b/core/modules/field/src/Tests/ConfigFieldDefinitionTest.php
index cfc13c3..99be2e0 100644
--- a/core/modules/field/src/Tests/ConfigFieldDefinitionTest.php
+++ b/core/modules/field/src/Tests/ConfigFieldDefinitionTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
@@ -55,7 +56,7 @@ public function setUp() {
public function testBundleFieldDefinition() {
$definitions = $this->entityManager->getFieldDefinitions($this->entityType, $this->bundle);
$this->assertTrue(isset($definitions[$this->instance->getName()]));
- $this->assertTrue($definitions[$this->instance->getName()] instanceof FieldStorageDefinitionInterface);
+ $this->assertTrue($definitions[$this->instance->getName()] instanceof FieldDefinitionInterface);
// Make sure no field for the instance on another entity type is exposed.
$this->assertFalse(isset($definitions[$this->instance_rev->getName()]));
}
diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php
index ba4ebd3..529065f 100644
--- a/core/modules/field/src/Tests/FormTest.php
+++ b/core/modules/field/src/Tests/FormTest.php
@@ -6,8 +6,7 @@
*/
namespace Drupal\field\Tests;
-
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests field form handling.
@@ -78,7 +77,7 @@ function setUp() {
'name' => 'field_unlimited',
'entity_type' => 'entity_test',
'type' => 'test_field',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->instance = array(
diff --git a/core/modules/field/src/Tests/NestedFormTest.php b/core/modules/field/src/Tests/NestedFormTest.php
index afadd26..b7f0708 100644
--- a/core/modules/field/src/Tests/NestedFormTest.php
+++ b/core/modules/field/src/Tests/NestedFormTest.php
@@ -6,8 +6,7 @@
*/
namespace Drupal\field\Tests;
-
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests field elements in nested forms.
@@ -44,7 +43,7 @@ public function setUp() {
'name' => 'field_unlimited',
'entity_type' => 'entity_test',
'type' => 'test_field',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->instance = array(
diff --git a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
index 9a25836..15a4914 100644
--- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
@@ -7,8 +7,7 @@
namespace Drupal\field\Tests\Views;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Language\Language;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
@@ -53,7 +52,7 @@ protected function setUp() {
'name' => 'field_name_3',
'entity_type' => 'node',
'type' => 'text',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
));
$field->save();
// Setup a field that will have no value.
@@ -61,7 +60,7 @@ protected function setUp() {
'name' => 'field_name_4',
'entity_type' => 'node',
'type' => 'text',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
));
$field->save();
diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import.yml
index 32f1cc8..aebef76 100644
--- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import.yml
+++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import.yml
@@ -8,7 +8,6 @@ settings:
module: text
locked: false
cardinality: 1
-translatable: false
indexes:
format:
- format
diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import_2.yml
index cd4bf75..6fcb85d 100644
--- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import_2.yml
+++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import_2.yml
@@ -8,7 +8,6 @@ settings:
module: text
locked: false
cardinality: 1
-translatable: false
indexes:
format:
- format
diff --git a/core/modules/field_ui/src/FieldOverview.php b/core/modules/field_ui/src/FieldOverview.php
index 46dff17..0d90e50 100644
--- a/core/modules/field_ui/src/FieldOverview.php
+++ b/core/modules/field_ui/src/FieldOverview.php
@@ -210,7 +210,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL
// contrib modules can form_alter() the value for newly created fields.
'translatable' => array(
'#type' => 'value',
- '#value' => FALSE,
+ '#value' => TRUE,
),
);
}
@@ -380,6 +380,8 @@ public function submitForm(array &$form, array &$form_state) {
'entity_type' => $this->entity_type,
'bundle' => $this->bundle,
'label' => $values['label'],
+ // Field translatability should be explicitly enabled by the users.
+ 'translatable' => FALSE,
);
// Create the field and instance.
diff --git a/core/modules/field_ui/src/Form/FieldEditForm.php b/core/modules/field_ui/src/Form/FieldEditForm.php
index 068bd71..fae7645 100644
--- a/core/modules/field_ui/src/Form/FieldEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldEditForm.php
@@ -8,6 +8,7 @@
namespace Drupal\field_ui\Form;
use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\TypedData\TypedDataManager;
use Drupal\field\FieldInstanceConfigInterface;
@@ -114,13 +115,13 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn
'#title_display' => 'invisible',
'#options' => array(
'number' => $this->t('Limited'),
- FieldInstanceConfigInterface::CARDINALITY_UNLIMITED => $this->t('Unlimited'),
+ FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED => $this->t('Unlimited'),
),
- '#default_value' => ($cardinality == FieldInstanceConfigInterface::CARDINALITY_UNLIMITED) ? FieldInstanceConfigInterface::CARDINALITY_UNLIMITED : 'number',
+ '#default_value' => ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 'number',
);
$form['field']['cardinality_container']['cardinality_number'] = array(
'#type' => 'number',
- '#default_value' => $cardinality != FieldInstanceConfigInterface::CARDINALITY_UNLIMITED ? $cardinality : 1,
+ '#default_value' => $cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ? $cardinality : 1,
'#min' => 1,
'#title' => $this->t('Limit'),
'#title_display' => 'invisible',
@@ -136,6 +137,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn
$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);
+ $form['field']['translatable'] = array('#type' => 'value', '#value' => $field->isTranslatable());
// Add settings provided by the field module. The field module is
// responsible for not returning settings that cannot be changed if
diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
index 505e8a1..367a3b0 100644
--- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
@@ -7,9 +7,9 @@
namespace Drupal\field_ui\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Language\Language;
use Drupal\Component\Utility\String;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Language\Language;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldInstanceConfig;
@@ -212,12 +212,12 @@ function cardinalitySettings() {
// Set to unlimited.
$edit = array(
- 'field[cardinality]' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'field[cardinality]' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Updated field Body field settings.');
$this->drupalGet($field_edit_path);
- $this->assertFieldByXPath("//select[@name='field[cardinality]']", FieldDefinitionInterface::CARDINALITY_UNLIMITED);
+ $this->assertFieldByXPath("//select[@name='field[cardinality]']", FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->assertFieldByXPath("//input[@name='field[cardinality_number]']", 1);
}
diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
index 0d052c5..48a6085 100644
--- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
+++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
@@ -7,10 +7,10 @@
namespace Drupal\file\Plugin\Field\FieldWidget;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Field\WidgetBase;
-use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Render\Element;
/**
@@ -83,7 +83,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
// Determine the number of widgets to display.
$cardinality = $this->fieldDefinition->getCardinality();
switch ($cardinality) {
- case FieldDefinitionInterface::CARDINALITY_UNLIMITED:
+ case FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED:
$max = count($items);
$is_multiple = TRUE;
break;
@@ -130,7 +130,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
}
$empty_single_allowed = ($cardinality == 1 && $delta == 0);
- $empty_multiple_allowed = ($cardinality == FieldDefinitionInterface::CARDINALITY_UNLIMITED || $delta < $cardinality) && empty($form_state['programmed']);
+ $empty_multiple_allowed = ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || $delta < $cardinality) && empty($form_state['programmed']);
// Add one more empty row for new uploads except when this is a programmed
// multiple form as it is not necessary.
diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php
index 219c083..e5cb710 100644
--- a/core/modules/file/src/Tests/FileFieldDisplayTest.php
+++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php
@@ -6,8 +6,7 @@
*/
namespace Drupal\file\Tests;
-
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests that formatters are working properly.
@@ -31,7 +30,7 @@ function testNodeDisplay() {
$field_settings = array(
'display_field' => '1',
'display_default' => '1',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
$instance_settings = array(
'description_field' => '1',
diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php
index d35a491..bab0f11 100644
--- a/core/modules/file/src/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/src/Tests/FileFieldValidateTest.php
@@ -7,7 +7,7 @@
namespace Drupal\file\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldInstanceConfig;
/**
@@ -54,7 +54,7 @@ function testRequired() {
// Try again with a multiple value field.
$field->delete();
- $this->createFileField($field_name, 'node', $type_name, array('cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED), array('required' => '1'));
+ $this->createFileField($field_name, 'node', $type_name, array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), array('required' => '1'));
// Try to post a new node without uploading a file in the multivalue field.
$edit = array();
diff --git a/core/modules/file/src/Tests/FileItemTest.php b/core/modules/file/src/Tests/FileItemTest.php
index 57b908a..6c6591a 100644
--- a/core/modules/file/src/Tests/FileItemTest.php
+++ b/core/modules/file/src/Tests/FileItemTest.php
@@ -7,9 +7,9 @@
namespace Drupal\file\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Tests\FieldUnitTestBase;
/**
@@ -49,7 +49,7 @@ public function setUp() {
'name' => 'file_test',
'entity_type' => 'entity_test',
'type' => 'file',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
diff --git a/core/modules/forum/config/install/field.field.taxonomy_term.forum_container.yml b/core/modules/forum/config/install/field.field.taxonomy_term.forum_container.yml
index a666915..3a4da5d 100644
--- a/core/modules/forum/config/install/field.field.taxonomy_term.forum_container.yml
+++ b/core/modules/forum/config/install/field.field.taxonomy_term.forum_container.yml
@@ -12,7 +12,6 @@ module: options
entity_type: taxonomy_term
locked: true
cardinality: 1
-translatable: false
indexes: { }
dependencies:
module:
diff --git a/core/modules/hal/src/Tests/NormalizerTestBase.php b/core/modules/hal/src/Tests/NormalizerTestBase.php
index c74854f..615862d 100644
--- a/core/modules/hal/src/Tests/NormalizerTestBase.php
+++ b/core/modules/hal/src/Tests/NormalizerTestBase.php
@@ -85,12 +85,12 @@ function setUp() {
'name' => 'field_test_text',
'entity_type' => 'entity_test',
'type' => 'text',
- 'translatable' => FALSE,
))->save();
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_text',
'bundle' => 'entity_test',
+ 'translatable' => FALSE,
))->save();
// Create the test translatable field.
@@ -98,12 +98,12 @@ function setUp() {
'name' => 'field_test_translatable_text',
'entity_type' => 'entity_test',
'type' => 'text',
- 'translatable' => TRUE,
))->save();
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_translatable_text',
'bundle' => 'entity_test',
+ 'translatable' => TRUE,
))->save();
// Create the test entity reference field.
@@ -111,7 +111,6 @@ function setUp() {
'name' => 'field_test_entity_reference',
'entity_type' => 'entity_test',
'type' => 'entity_reference',
- 'translatable' => TRUE,
'settings' => array(
'target_type' => 'entity_test',
),
@@ -120,6 +119,7 @@ function setUp() {
'entity_type' => 'entity_test',
'field_name' => 'field_test_entity_reference',
'bundle' => 'entity_test',
+ 'translatable' => TRUE,
))->save();
$entity_manager = \Drupal::entityManager();
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index 5adddef..9a5e8dc 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -7,7 +7,7 @@
namespace Drupal\image\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
/**
@@ -245,7 +245,7 @@ function testImageFieldSettings() {
// 1, so we need to make sure the file widget prevents these notices by
// providing all settings, even if they are not used.
// @see FileWidget::formMultipleElements().
- $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/field', array('field[cardinality]' => FieldDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
+ $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/field', array('field[cardinality]' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
$edit = array();
$edit['files[' . $field_name . '_1][]'] = drupal_realpath($test_image->uri);
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
diff --git a/core/modules/image/src/Tests/ImageItemTest.php b/core/modules/image/src/Tests/ImageItemTest.php
index e17987b..53472a8 100644
--- a/core/modules/image/src/Tests/ImageItemTest.php
+++ b/core/modules/image/src/Tests/ImageItemTest.php
@@ -7,9 +7,9 @@
namespace Drupal\image\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Tests\FieldUnitTestBase;
/**
@@ -54,7 +54,7 @@ public function setUp() {
'name' => 'image_test',
'entity_type' => 'entity_test',
'type' => 'image',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
index fb83895..64bfdf1 100644
--- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
@@ -7,7 +7,7 @@
namespace Drupal\image\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
@@ -49,7 +49,7 @@ public function setUp() {
'name' => 'image_test',
'entity_type' => 'entity_test',
'type' => 'image',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module
index 0d9494e..d37258f 100644
--- a/core/modules/node/tests/modules/node_access_test/node_access_test.module
+++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module
@@ -85,7 +85,8 @@ function node_access_test_entity_base_field_info(EntityTypeInterface $entity_typ
if ($entity_type->id() === 'node') {
$fields['private'] = FieldDefinition::create('boolean')
->setLabel(t('Private'))
- ->setComputed(TRUE);
+ ->setComputed(TRUE)
+ ->setCustomStorage(TRUE);
return $fields;
}
diff --git a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
index 15d8ca9..8335a8a 100644
--- a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
+++ b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
@@ -8,7 +8,7 @@
namespace Drupal\quickedit\Tests;
use Drupal\Component\Serialization\Json;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
@@ -85,7 +85,7 @@ protected function setUp() {
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php b/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php
index f733014..f71b37d 100644
--- a/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php
+++ b/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php
@@ -6,6 +6,7 @@
namespace Drupal\rdf\Tests\Field;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\rdf\Tests\Field\FieldRdfaTestBase;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
@@ -63,7 +64,7 @@ public function setUp() {
'name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php b/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php
index 82b8516..2c84d0f 100644
--- a/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php
+++ b/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php
@@ -7,7 +7,7 @@
namespace Drupal\rdf\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\taxonomy\Tests\TaxonomyTestBase;
/**
@@ -159,7 +159,7 @@ protected function createTaxonomyTermReferenceField($field_name, $vocabulary) {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php
index 80f0261..8317dde 100644
--- a/core/modules/shortcut/src/Entity/Shortcut.php
+++ b/core/modules/shortcut/src/Entity/Shortcut.php
@@ -203,7 +203,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['path'] = FieldDefinition::create('string')
->setLabel(t('Path'))
->setDescription(t('The computed shortcut path.'))
- ->setComputed(TRUE);
+ ->setComputed(TRUE)
+ ->setCustomStorage(TRUE);
$item_definition = $fields['path']->getItemDefinition();
$item_definition->setClass('\Drupal\shortcut\ShortcutPathItem');
diff --git a/core/modules/system/src/Tests/Ajax/MultiFormTest.php b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
index 5eb13e5..16d19a7 100644
--- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php
+++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
@@ -6,8 +6,7 @@
*/
namespace Drupal\system\Tests\Ajax;
-
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests Ajax-enabled forms functionality with multiple instances of the form.
@@ -40,7 +39,7 @@ function setUp() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance_config', array(
'field_name' => $field_name,
diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
index 8a2fbe7..8c4b1bd 100644
--- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
@@ -11,7 +11,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\EventSubscriber\HtmlViewSubscriber;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\system\Tests\Cache\PageCacheTagsTestBase;
/**
@@ -163,7 +163,7 @@ protected function createReferenceTestEntities($referenced_entity) {
'name' => $field_name,
'entity_type' => $entity_type,
'type' => 'entity_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'target_type' => $referenced_entity->getEntityTypeId(),
),
diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
index c76fc97..3be40c6 100644
--- a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
@@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Entity;
use Drupal\Core\Language\Language;
-use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldInstanceConfig;
/**
* Base class for language-aware entity tests.
@@ -75,12 +75,12 @@ function setUp() {
'entity_type' => $entity_type,
'type' => 'text',
'cardinality' => 4,
- 'translatable' => TRUE,
))->save();
entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => $entity_type,
'bundle' => $entity_type,
+ 'translatable' => TRUE,
))->save();
$this->instance[$entity_type] = entity_load('field_instance_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
@@ -89,12 +89,12 @@ function setUp() {
'entity_type' => $entity_type,
'type' => 'text',
'cardinality' => 4,
- 'translatable' => FALSE,
))->save();
entity_create('field_instance_config', array(
'field_name' => $this->untranslatable_field_name,
'entity_type' => $entity_type,
'bundle' => $entity_type,
+ 'translatable' => FALSE,
))->save();
}
@@ -124,15 +124,15 @@ function setUp() {
* @param string $entity_type
* The type of the entity fields are attached to.
*/
- protected function toggleFieldTranslatability($entity_type) {
+ protected function toggleFieldTranslatability($entity_type, $bundle) {
$fields = array($this->field_name, $this->untranslatable_field_name);
foreach ($fields as $field_name) {
- $field = FieldConfig::loadByName($entity_type, $field_name);
- $translatable = !$field->isTranslatable();
- $field->set('translatable', $translatable);
- $field->save();
- $field = FieldConfig::loadByName($entity_type, $field_name);
- $this->assertEqual($field->isTranslatable(), $translatable, 'Field translatability changed.');
+ $instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field_name);
+ $translatable = !$instance->isTranslatable();
+ $instance->set('translatable', $translatable);
+ $instance->save();
+ $instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field_name);
+ $this->assertEqual($instance->isTranslatable(), $translatable, 'Field translatability changed.');
}
\Drupal::cache('entity')->deleteAll();
}
diff --git a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php
index b9d8cec..cc4ed0f 100644
--- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php
+++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php
@@ -55,7 +55,7 @@ public function testFieldSqlStorage() {
// Test that after switching field translatability things keep working as
// before.
- $this->toggleFieldTranslatability($entity_type);
+ $this->toggleFieldTranslatability($entity_type, $entity_type);
$entity = $this->reloadEntity($entity);
foreach (array($this->field_name, $this->untranslatable_field_name) as $field_name) {
$this->assertEqual($entity->get($field_name)->value, $values[$field_name], 'Field language works as expected after switching translatability.');
@@ -63,14 +63,14 @@ public function testFieldSqlStorage() {
// Test that after disabling field translatability translated values are not
// loaded.
- $this->toggleFieldTranslatability($entity_type);
+ $this->toggleFieldTranslatability($entity_type, $entity_type);
$entity = $this->reloadEntity($entity);
$entity->langcode->value = $this->langcodes[0];
$translation = $entity->addTranslation($this->langcodes[1]);
$translated_value = $this->randomName();
$translation->get($this->field_name)->value = $translated_value;
$translation->save();
- $this->toggleFieldTranslatability($entity_type);
+ $this->toggleFieldTranslatability($entity_type, $entity_type);
$entity = $this->reloadEntity($entity);
$this->assertEqual($entity->getTranslation($this->langcodes[1])->get($this->field_name)->value, $values[$this->field_name], 'Existing field translations are not loaded for untranslatable fields.');
}
diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php
index 1f91e80..f8cd8b0 100644
--- a/core/modules/system/src/Tests/Form/RebuildTest.php
+++ b/core/modules/system/src/Tests/Form/RebuildTest.php
@@ -7,7 +7,7 @@
namespace Drupal\system\Tests\Form;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
@@ -76,7 +76,7 @@ function testPreserveFormActionAfterAJAX() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
entity_create('field_config', $field)->save();
$instance = array(
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install
index 015b067..162f7ea 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.install
+++ b/core/modules/system/tests/modules/entity_test/entity_test.install
@@ -22,13 +22,13 @@ function entity_test_install() {
'entity_type' => $entity_type,
'type' => 'text',
'cardinality' => 1,
- 'translatable' => FALSE,
))->save();
entity_create('field_instance_config', array(
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'bundle' => $entity_type,
'label' => 'Test text-field',
+ 'translatable' => FALSE,
))->save();
entity_get_form_display($entity_type, $entity_type, 'default')
diff --git a/core/modules/taxonomy/src/Tests/LegacyTest.php b/core/modules/taxonomy/src/Tests/LegacyTest.php
index c7035c9..bf7ae23 100644
--- a/core/modules/taxonomy/src/Tests/LegacyTest.php
+++ b/core/modules/taxonomy/src/Tests/LegacyTest.php
@@ -8,7 +8,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Datetime\DrupalDateTime;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Test for legacy node bug.
@@ -45,7 +45,7 @@ function setUp() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/RssTest.php b/core/modules/taxonomy/src/Tests/RssTest.php
index 709d0fa..81ed1b3 100644
--- a/core/modules/taxonomy/src/Tests/RssTest.php
+++ b/core/modules/taxonomy/src/Tests/RssTest.php
@@ -7,7 +7,7 @@
namespace Drupal\taxonomy\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests the rendering of term reference fields in RSS feeds.
@@ -41,7 +41,7 @@ function setUp() {
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php
index 78c877f..f74774b 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php
@@ -7,9 +7,9 @@
namespace Drupal\taxonomy\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\field\Tests\FieldUnitTestBase;
@@ -55,7 +55,7 @@ public function setUp() {
'name' => 'field_test_taxonomy',
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php
index 8ec55e7..cfe29f9 100644
--- a/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php
+++ b/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php
@@ -7,7 +7,7 @@
namespace Drupal\taxonomy\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
/**
@@ -47,7 +47,7 @@ function setUp() {
'name' => $this->field_name,
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/TermIndexTest.php b/core/modules/taxonomy/src/Tests/TermIndexTest.php
index e79d159..ce4c8fd 100644
--- a/core/modules/taxonomy/src/Tests/TermIndexTest.php
+++ b/core/modules/taxonomy/src/Tests/TermIndexTest.php
@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests the hook implementations that maintain the taxonomy index.
@@ -37,7 +38,7 @@ function setUp() {
'name' => $this->field_name_1,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
@@ -68,7 +69,7 @@ function setUp() {
'name' => $this->field_name_2,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php
index d309e30..e08cf24 100644
--- a/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTest.php
@@ -8,9 +8,9 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Component\Serialization\Json;
-use Drupal\Component\Utility\Tags;
-use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\Tags;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
/**
@@ -37,7 +37,7 @@ function setUp() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
index a09cbc2..241883b 100644
--- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
@@ -7,10 +7,9 @@
namespace Drupal\taxonomy\Tests;
-use Drupal\Component\Utility\Xss;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Language\Language;
use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\Xss;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Test taxonomy token replacement in strings.
@@ -35,7 +34,7 @@ function setUp() {
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
index 2cc992e..f86b2dc 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
@@ -7,7 +7,7 @@
namespace Drupal\taxonomy\Tests\Views;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
@@ -83,7 +83,7 @@ protected function mockStandardInstall() {
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php
index 6c0fb85..a484f27 100644
--- a/core/modules/user/src/Entity/User.php
+++ b/core/modules/user/src/Entity/User.php
@@ -8,11 +8,11 @@
namespace Drupal\user\Entity;
use Drupal\Core\Entity\ContentEntityBase;
-use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityMalformedException;
+use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldDefinition;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\user\UserInterface;
/**
@@ -533,7 +533,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['roles'] = FieldDefinition::create('string')
->setCustomStorage(TRUE)
->setLabel(t('Roles'))
- ->setCardinality(FieldDefinitionInterface::CARDINALITY_UNLIMITED)
+ ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setDescription(t('The roles the user has.'));
return $fields;
diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php
index a0b205c..566776e 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -7,8 +7,7 @@
namespace Drupal\user\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Language\Language;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
@@ -255,7 +254,7 @@ function testRegistrationWithUserFields() {
$this->assertEqual($new_user->test_user_field->value, $value, 'The field value was correclty saved.');
// Check that the 'add more' button works.
- $field->cardinality = FieldDefinitionInterface::CARDINALITY_UNLIMITED;
+ $field->cardinality = FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED;
$field->save();
foreach (array('js', 'nojs') as $js) {
$this->drupalGet('user/register');
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index b960d5b..14eb5aa 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -180,11 +180,11 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
$this->unpackOptions($this->options, $options);
}
- // Convert the field_language and field_language_add_to_query settings.
- $field_language = $this->getOption('field_language');
+ // Convert the field_langcode and field_language_add_to_query settings.
+ $field_langcode = $this->getOption('field_langcode');
$field_language_add_to_query = $this->getOption('field_language_add_to_query');
if (isset($field_langcode)) {
- $this->setOption('field_langcode', $field_language);
+ $this->setOption('field_langcode', $field_langcode);
$this->setOption('field_langcode_add_to_query', $field_language_add_to_query);
$changed = TRUE;
}
@@ -1950,7 +1950,7 @@ public function submitOptionsForm(&$form, &$form_state) {
case 'group_by':
$this->setOption($section, $form_state['values'][$section]);
break;
- case 'field_language':
+ case 'field_langcode':
$this->setOption('field_langcode', $form_state['values']['field_langcode']);
$this->setOption('field_langcode_add_to_query', $form_state['values']['field_langcode_add_to_query']);
break;
diff --git a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
index 175ebcb..88a0d35 100644
--- a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
+++ b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
@@ -7,7 +7,7 @@
namespace Drupal\views\Tests\Wizard;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests the ability of the views wizard to create views filtered by taxonomy.
@@ -59,7 +59,7 @@ function setUp() {
'name' => 'field_views_testing_tags',
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
- 'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
+ 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
diff --git a/core/profiles/standard/config/install/field.field.node.field_image.yml b/core/profiles/standard/config/install/field.field.node.field_image.yml
index 4b81618..d5df17f 100644
--- a/core/profiles/standard/config/install/field.field.node.field_image.yml
+++ b/core/profiles/standard/config/install/field.field.node.field_image.yml
@@ -13,7 +13,6 @@ settings:
height: null
locked: false
cardinality: 1
-translatable: false
indexes:
target_id:
- target_id
diff --git a/core/profiles/standard/config/install/field.field.node.field_tags.yml b/core/profiles/standard/config/install/field.field.node.field_tags.yml
index d4bd7c3..e9bd31c 100644
--- a/core/profiles/standard/config/install/field.field.node.field_tags.yml
+++ b/core/profiles/standard/config/install/field.field.node.field_tags.yml
@@ -10,7 +10,6 @@ settings:
parent: 0
locked: false
cardinality: -1
-translatable: false
indexes:
target_id:
- target_id
diff --git a/core/profiles/standard/config/install/field.field.user.user_picture.yml b/core/profiles/standard/config/install/field.field.user.user_picture.yml
index 986d7bf..6c7259d 100644
--- a/core/profiles/standard/config/install/field.field.user.user_picture.yml
+++ b/core/profiles/standard/config/install/field.field.user.user_picture.yml
@@ -15,7 +15,6 @@ settings:
module: image
locked: false
cardinality: 1
-translatable: false
indexes:
target_id:
- target_id
diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
index cc77d6d..3809fad 100644
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
@@ -248,7 +248,7 @@ public function testGetSchema() {
),
);
- $this->fieldDefinitions['id'] = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $this->fieldDefinitions['id'] = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$this->fieldDefinitions['id']->expects($this->once())
->method('getColumns')
->will($this->returnValue($columns));
@@ -365,7 +365,7 @@ public function testGetTableMappingSimpleWithFields(array $entity_keys) {
$base_field_names = array('title', 'description', 'owner');
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
- $definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $definition = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$this->fieldDefinitions = array_fill_keys($field_names, $definition);
$this->entityType->expects($this->any())
@@ -501,11 +501,11 @@ public function testGetTableMappingRevisionableWithFields(array $entity_keys) {
$base_field_names = array('title');
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
- $definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $definition = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$this->fieldDefinitions = array_fill_keys($field_names, $definition);
$revisionable_field_names = array('description', 'owner');
- $definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $definition = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
// isRevisionable() is only called once, but we re-use the same definition
// for all revisionable fields.
$definition->expects($this->any())
@@ -626,7 +626,7 @@ public function testGetTableMappingTranslatableWithFields(array $entity_keys) {
$base_field_names = array('title', 'description', 'owner');
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
- $definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $definition = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$this->fieldDefinitions = array_fill_keys($field_names, $definition);
$this->entityType->expects($this->exactly(2))
@@ -808,11 +808,11 @@ public function testGetTableMappingRevisionableTranslatableWithFields(array $ent
$base_field_names = array('title');
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
- $definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $definition = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$this->fieldDefinitions = array_fill_keys($field_names, $definition);
$revisionable_field_names = array('description', 'owner');
- $definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
+ $definition = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
// isRevisionable() is only called once, but we re-use the same definition
// for all revisionable fields.
$definition->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
index 9637ccb..7f8e1b5 100644
--- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
@@ -9,7 +9,7 @@
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Field\FieldDefinition;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Tests\UnitTestCase;
/**
@@ -190,8 +190,8 @@ public function testFieldCardinality() {
$this->assertEquals(1, $definition->getCardinality());
$definition->setCardinality(2);
$this->assertEquals(2, $definition->getCardinality());
- $definition->setCardinality(FieldDefinitionInterface::CARDINALITY_UNLIMITED);
- $this->assertEquals(FieldDefinitionInterface::CARDINALITY_UNLIMITED, $definition->getCardinality());
+ $definition->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
+ $this->assertEquals(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, $definition->getCardinality());
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Entity/Schema/ContentEntitySchemaHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Schema/ContentEntitySchemaHandlerTest.php
index b39fbcb..3ac9d53 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Schema/ContentEntitySchemaHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Schema/ContentEntitySchemaHandlerTest.php
@@ -750,7 +750,7 @@ protected function setUpSchemaHandler() {
* The field name.
* @param array $schema
* The schema array of the field definition, as returned from
- * FieldDefinitionInterface::schema().
+ * FieldStorageDefinitionInterface::getSchema().
*/
public function setUpStorageDefinition($field_name, array $schema) {
$this->storageDefinitions[$field_name] = $this->getMock('Drupal\Core\Field\FieldStorageDefinitionInterface');