diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
index a60122fb77e..8bf2c4e7a64 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\Query\QueryInterface;
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\LanguageInterface;
-use Drupal\field\FieldConfigUpdateForbiddenException;
-use Drupal\field\FieldConfigInterface;
-use Drupal\field\FieldInstanceConfigInterface;
use Drupal\field\Entity\FieldConfig;
+use Drupal\field\FieldConfigInterface;
+use Drupal\field\FieldConfigUpdateForbiddenException;
+use Drupal\field\FieldInstanceConfigInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -239,11 +238,11 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
public function getTableMapping() {
if (!isset($this->tableMapping)) {
- $definitions = array_filter($this->getFieldStorageDefinitions(), function (FieldDefinitionInterface $definition) {
+ $definitions = array_filter($this->getFieldStorageDefinitions(), 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);
@@ -956,10 +955,12 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
// 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();
+ $fields[$field_name] = $instance->getFieldStorageDefinition();
}
}
}
@@ -982,10 +983,11 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
$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;
}
@@ -1028,7 +1030,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
if (!($instance instanceof FieldInstanceConfigInterface)) {
continue;
}
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$table_name = static::_fieldTableName($field);
$revision_name = static::_fieldRevisionTableName($field);
@@ -1105,7 +1107,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
if (!($instance instanceof FieldInstanceConfigInterface)) {
continue;
}
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$table_name = static::_fieldTableName($field);
$revision_name = static::_fieldRevisionTableName($field);
$this->database->delete($table_name)
@@ -1127,7 +1129,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
if (!($instance instanceof FieldInstanceConfigInterface)) {
continue;
}
- $revision_name = static::_fieldRevisionTableName($instance->getField());
+ $revision_name = static::_fieldRevisionTableName($instance->getFieldStorageDefinition());
$this->database->delete($revision_name)
->condition('entity_id', $entity->id())
->condition('revision_id', $vid)
@@ -1258,7 +1260,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
* {@inheritdoc}
*/
public function onInstanceDelete(FieldInstanceConfigInterface $instance) {
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$table_name = static::_fieldTableName($field);
$revision_name = static::_fieldRevisionTableName($field);
$this->database->update($table_name)
@@ -1280,7 +1282,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
// using the old bundle name.
$instances = entity_load_multiple_by_properties('field_instance_config', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'include_deleted' => TRUE));
foreach ($instances as $instance) {
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$table_name = static::_fieldTableName($field);
$revision_name = static::_fieldRevisionTableName($field);
$this->database->update($table_name)
@@ -1298,7 +1300,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
* {@inheritdoc}
*/
protected function readFieldItemsToPurge(EntityInterface $entity, FieldInstanceConfigInterface $instance) {
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$table_name = static::_fieldTableName($field);
$query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC))
->condition('entity_id', $entity->id())
@@ -1313,7 +1315,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
* {@inheritdoc}
*/
public function purgeFieldItems(EntityInterface $entity, FieldInstanceConfigInterface $instance) {
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$table_name = static::_fieldTableName($field);
$revision_name = static::_fieldRevisionTableName($field);
$this->database->delete($table_name)
diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php
index 006ceb008a2..1c0777dda4b 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinition.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinition.php
@@ -15,7 +15,7 @@ use Drupal\field\FieldException;
/**
* 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 @@ class FieldDefinition extends ListDataDefinition implements FieldDefinitionInter
* 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.
@@ -592,4 +592,11 @@ class FieldDefinition extends ListDataDefinition implements FieldDefinitionInter
return $this;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getFieldStorageDefinition() {
+ return $this;
+ }
+
}
diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
index 8a7fb98a11d..2933656fde0 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
@@ -52,7 +52,28 @@ use Drupal\Core\TypedData\ListDataDefinitionInterface;
* 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 the machine name of the field.
+ *
+ * This defines how the field data is accessed from the entity. For example,
+ * if the field name is "foo", then $entity->foo returns its data.
+ *
+ * @return string
+ * The field name.
+ */
+ public function getName();
+
+ /**
+ * Returns the field type.
+ *
+ * @return string
+ * The field type, i.e. the id of a field type plugin. For example 'text'.
+ *
+ * @see \Drupal\Core\Field\FieldTypePluginManagerInterface
+ */
+ public function getType();
/**
* Returns whether the display for the field can be configured.
@@ -131,4 +152,29 @@ interface FieldDefinitionInterface extends FieldStorageDefinitionInterface, List
*/
public function getDefaultValue(ContentEntityInterface $entity);
+ /**
+ * Returns whether the field is translatable.
+ *
+ * @return bool
+ * TRUE if the field is translatable.
+ */
+ public function isTranslatable();
+
+ /**
+ * Sets whether the field is translatable.
+ *
+ * @param bool $translatable
+ * Whether the field is translatable.
+ *
+ * @return $this
+ */
+ public function setTranslatable($translatable);
+
+ /**
+ * Returns the field storage definition.
+ *
+ * @return \Drupal\Core\Field\FieldStorageDefinitionInterface
+ * The field storage definition.
+ */
+ public function getFieldStorageDefinition();
}
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index c715902e145..4305ccdf230 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -7,12 +7,12 @@
namespace Drupal\Core\Field;
+use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Entity\ContentEntityInterface;
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\LanguageInterface;
+use Drupal\Core\TypedData\TypedDataInterface;
/**
* Represents an entity field; that is, a list of field item objects.
@@ -285,8 +285,8 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
// 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()->getCardinality();
- if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
+ $cardinality = $this->getFieldDefinition()->getFieldStorageDefinition()->getCardinality();
+ 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 6dc980827b8..161b0b38a30 100644
--- a/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php
@@ -77,13 +77,23 @@ interface FieldStorageDefinitionInterface {
public function getSetting($setting_name);
/**
- * Returns whether the field is translatable.
+ * Returns whether the field supports translation.
*
* @return bool
- * TRUE if the field is translatable.
+ * TRUE if the field supports translation.
*/
public function isTranslatable();
+ /**
+ * Sets whether the field supports translation.
+ *
+ * @param bool $translatable
+ * Whether the field supports translation.
+ *
+ * @return $this
+ */
+ public function setTranslatable($translatable);
+
/**
* Returns whether the field is revisionable.
*
@@ -193,8 +203,8 @@ interface FieldStorageDefinitionInterface {
* 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 @@ interface FieldStorageDefinitionInterface {
* 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/TypedData/FieldItemDataDefinition.php b/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
index dbf81c63d7f..c18e9878a2c 100644
--- a/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
+++ b/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
@@ -61,21 +61,21 @@ class FieldItemDataDefinition extends DataDefinition implements ComplexDataDefin
* {@inheritdoc}
*/
public function getPropertyDefinition($name) {
- return $this->fieldDefinition->getPropertyDefinition($name);
+ return $this->fieldDefinition->getFieldStorageDefinition()->getPropertyDefinition($name);
}
/**
* {@inheritdoc}
*/
public function getPropertyDefinitions() {
- return $this->fieldDefinition->getPropertyDefinitions();
+ return $this->fieldDefinition->getFieldStorageDefinition()->getPropertyDefinitions();
}
/**
* {@inheritdoc}
*/
public function getMainPropertyName() {
- return $this->fieldDefinition->getMainPropertyName();
+ return $this->fieldDefinition->getFieldStorageDefinition()->getMainPropertyName();
}
}
diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php
index 18602f47480..b366cd4e02a 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -142,12 +142,12 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
*/
protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) {
$field_name = $this->fieldDefinition->getName();
- $cardinality = $this->fieldDefinition->getCardinality();
+ $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
$parents = $form['#parents'];
// Determine the number of widgets to display.
switch ($cardinality) {
- case FieldDefinitionInterface::CARDINALITY_UNLIMITED:
+ case FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED:
$field_state = field_form_get_state($parents, $field_name, $form_state);
$max = $field_state['items_count'];
$is_multiple = TRUE;
@@ -198,7 +198,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
'#theme' => 'field_multiple_value_form',
'#field_name' => $field_name,
'#cardinality' => $cardinality,
- '#cardinality_multiple' => $this->fieldDefinition->isMultiple(),
+ '#cardinality_multiple' => $this->fieldDefinition->getFieldStorageDefinition()->isMultiple(),
'#required' => $this->fieldDefinition->isRequired(),
'#title' => $title,
'#description' => $description,
@@ -206,7 +206,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
);
// Add 'add more' button, if not working with a programmed form.
- if ($cardinality == FieldDefinitionInterface::CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
+ if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
$id_prefix = implode('-', array_merge($parents, array($field_name)));
$wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
@@ -264,7 +264,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
$element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1));
// Ensure the widget allows adding additional items.
- if ($element['#cardinality'] != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
+ if ($element['#cardinality'] != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
return;
}
diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc
index d2a3e1ea26b..343a108e351 100644
--- a/core/modules/content_translation/content_translation.admin.inc
+++ b/core/modules/content_translation/content_translation.admin.inc
@@ -6,10 +6,10 @@
*/
use Drupal\Component\Utility\String;
+use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Render\Element;
-use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldInstanceConfigInterface;
/**
@@ -79,7 +79,9 @@ 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);
+ $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : 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 +100,33 @@ 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()) {
$form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = array(
'#label' => $definition->getLabel(),
'#type' => 'checkbox',
- '#default_value' => $translatable,
+ '#default_value' => $definition->isTranslatable(),
);
- $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.
+ // @todo Remove this special casing when arbitrary settings can be
+ // stored for any field. See https://drupal.org/node/2224761.
+ 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 +291,40 @@ 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;
+ }
+ // 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.
+ // @todo Remove this special casing when any field definition can have
+ // a configurable bundle override. See
+ // https://drupal.org/node/2224761.
+ $definition = $definitions[$field_name];
+ if ($definition instanceof FieldInstanceConfigInterface) {
+ if ($definition->isTranslatable() != $translatable) {
+ $definition->setTranslatable($translatable);
+ $definition->save();
+ }
+ // Do not save configurable fields unnecessarily.
+ unset($bundle_settings['fields'][$field_name]);
}
}
}
}
}
- _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;
- }
- }
- }
- }
- // 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 1023c178c8f..827383150ad 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -5,16 +5,13 @@
* 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\Language\LanguageInterface;
-use Drupal\Core\Session\AccountInterface;
-use Drupal\Core\TypedData\TranslatableInterface;
use Drupal\field\Entity\FieldInstanceConfig;
+use Drupal\field\FieldInstanceConfigInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -145,23 +142,28 @@ function content_translation_entity_bundle_info_alter(&$bundles) {
}
/**
- * Implements hook_entity_base_field_info_alter().
+ * Implements hook_entity_bundle_field_info_alter().
+ *
+ * @todo Remove this when any field supports per-bundle configurable overrides.
+ * See https://drupal.org/node/2224761.
*/
-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 $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) {
- $fields[$name]->setTranslatable((bool) $translatable);
+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)) {
+ $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($fields[$name]) || !$fields[$name] instanceof FieldInstanceConfigInterface) {
+ // If we do not have a bundle definition for the current field and we
+ // have to override its translatability, we need to instantiate a new
+ // bundle field definition from the base one.
+ if (!isset($fields[$name]) && isset($base_field_definitions[$name]) && $base_field_definitions[$name]->isTranslatable() != $translatable) {
+ $fields[$name] = clone $base_field_definitions[$name];
+ }
+ if (isset($fields[$name])) {
+ $fields[$name]->setTranslatable((bool) $translatable);
+ }
}
}
}
@@ -636,58 +638,37 @@ function content_translation_entity_extra_field_info() {
}
/**
- * Implements hook_form_FORM_ID_alter() for 'field_ui_field_edit_form'.
+ * Implements hook_form_FORM_ID_alter() for 'field_ui_instance_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->getFieldStorageDefinition()->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 084900ce93f..0db65201397 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
@@ -9,7 +9,7 @@ namespace Drupal\content_translation\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Language\Language;
-use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\simpletest\WebTestBase;
/**
@@ -22,7 +22,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(
@@ -40,6 +40,7 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->drupalCreateContentType(array('type' => 'article'));
$this->drupalCreateContentType(array('type' => 'page'));
$this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment_article', CommentItemInterface::OPEN, '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', 'administer comments', 'administer comment types'));
$this->drupalLogin($admin_user);
@@ -95,8 +96,24 @@ class ContentTranslationSettingsTest extends WebTestBase {
'settings[comment][comment_article][fields][comment_body]' => TRUE,
);
$this->assertSettings('comment', 'comment_article', TRUE, $edit);
- $field = FieldConfig::loadByName('comment', 'comment_body');
- $this->assertTrue($field->isTranslatable(), 'Comment body is translatable.');
+ $definition = $this->entityManager()->getFieldDefinitions('comment', 'comment_article')['comment_body'];
+ $this->assertTrue($definition->isTranslatable(), 'Article comment body is translatable.');
+ $definition = $this->entityManager()->getFieldDefinitions('comment', 'comment')['comment_body'];
+ $this->assertFalse($definition->isTranslatable(), 'Page comment body is not translatable.');
+ $this->assertNull(content_translation_get_config('comment', 'comment_article', 'fields'), 'Configurable fields are not saved to content_translation.settings.');
+
+ // 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,
+ 'settings[entity_test_mul][entity_test_mul][fields][user_id]' => FALSE,
+ );
+ $this->assertSettings('entity_test_mul', 'entity_test_mul', TRUE, $edit);
+ $settings = content_translation_get_config('entity_test_mul', 'entity_test_mul', 'fields');
+ $this->assertTrue($settings['name'] && !$settings['user_id'], 'Base fields are saved to content_translation.settings.');
+ $definitions = $this->entityManager()->getFieldDefinitions('entity_test_mul', 'entity_test_mul');
+ $this->assertTrue($definitions['name']->isTranslatable() && !$definitions['user_id']->isTranslatable(), 'Bundle field definitions were correctly altered.');
// Test that language settings are correctly stored.
$language_configuration = language_get_default_configuration('comment', 'comment_article');
@@ -134,20 +151,20 @@ class ContentTranslationSettingsTest extends WebTestBase {
// 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.');
}
}
@@ -196,9 +213,9 @@ class ContentTranslationSettingsTest extends WebTestBase {
// 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
@@ -214,4 +231,14 @@ class ContentTranslationSettingsTest extends WebTestBase {
$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/editor/src/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
index facc818c5cd..d729943b32b 100644
--- a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
+++ b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
@@ -29,7 +29,7 @@ class Editor extends PluginBase implements InPlaceEditorInterface {
$field_definition = $items->getFieldDefinition();
// This editor is incompatible with multivalued fields.
- if ($field_definition->getCardinality() != 1) {
+ if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) {
return FALSE;
}
// This editor is compatible with processed ("rich") text fields; but only
diff --git a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php
index 1d18deb2909..ae4f5fcd85c 100644
--- a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php
+++ b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php
@@ -109,12 +109,12 @@ class SelectionBase implements SelectionInterface {
});
foreach ($bundle_fields as $instance_name => $field_definition) {
/* @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
- $columns = $field_definition->getColumns();
+ $columns = $field_definition->getFieldStorageDefinition()->getColumns();
// If there is more than one column, display them all, otherwise just
// display the field label.
// @todo: Use property labels instead of the column name.
if (count($columns) > 1) {
- foreach ($field_definition->getColumns() as $column_name => $column_info) {
+ foreach ($columns as $column_name => $column_info) {
$fields[$instance_name . '.' . $column_name] = t('@label (@column)', array('@label' => $field_definition->getLabel(), '@column' => $column_name));
}
}
diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php
index 9c2420bd059..61e3308b422 100644
--- a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php
+++ b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php
@@ -7,7 +7,7 @@
namespace Drupal\entity_reference\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
@@ -44,7 +44,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase {
'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/entity_reference/src/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php
index 2ab3fa6488a..d5357ba1acd 100644
--- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php
+++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php
@@ -7,10 +7,10 @@
namespace Drupal\entity_reference\Tests;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
-use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests for the entity reference field.
@@ -88,7 +88,7 @@ class EntityReferenceFieldTest extends EntityUnitTestBase {
$this->referencedEntityType,
'default',
array('target_bundles' => array($this->bundle)),
- FieldDefinitionInterface::CARDINALITY_UNLIMITED
+ FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED
);
$this->field = FieldConfig::loadByName($this->entityType, $this->fieldName);
diff --git a/core/modules/field/config/schema/field.schema.yml b/core/modules/field/config/schema/field.schema.yml
index a00c89e6e31..788f3a0438d 100644
--- a/core/modules/field/config/schema/field.schema.yml
+++ b/core/modules/field/config/schema/field.schema.yml
@@ -76,6 +76,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/field.purge.inc b/core/modules/field/field.purge.inc
index a19621d53cb..44719706ebc 100644
--- a/core/modules/field/field.purge.inc
+++ b/core/modules/field/field.purge.inc
@@ -98,7 +98,7 @@ function field_purge_batch($batch_size, $field_uuid = NULL) {
);
// Retrieve some entities.
$query = $factory->get($entity_type)
- ->condition('id:' . $instance->getField()->uuid() . '.deleted', 1)
+ ->condition('id:' . $instance->getFieldStorageDefinition()->uuid() . '.deleted', 1)
->range(0, $batch_size);
// If there's no bundle key, all results will have the same bundle.
if ($bundle_key = $info[$entity_type]->getKey('bundle')) {
diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php
index 6e0aa46554f..10282ef8032 100644
--- a/core/modules/field/src/Entity/FieldConfig.php
+++ b/core/modules/field/src/Entity/FieldConfig.php
@@ -111,11 +111,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.
@@ -544,12 +544,7 @@ class FieldConfig extends ConfigEntityBase implements FieldConfigInterface {
}
/**
- * 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 77d1cf3d8b6..ed1400b6270 100644
--- a/core/modules/field/src/Entity/FieldInstanceConfig.php
+++ b/core/modules/field/src/Entity/FieldInstanceConfig.php
@@ -120,6 +120,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.
*
@@ -264,6 +273,21 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return $this->entity_type . '.' . $this->bundle . '.' . $this->field_name;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getName() {
+ return $this->field_name;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getType() {
+ return $this->getFieldStorageDefinition()->getType();
+ }
+
+
/**
* {@inheritdoc}
*/
@@ -282,7 +306,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
public function postCreate(EntityStorageInterface $storage) {
// Validate that we have a valid field for this instance. This throws an
// exception if the field is invalid.
- $field = $this->getField();
+ $field = $this->getFieldStorageDefinition();
// Make sure the field_uuid is populated.
$this->field_uuid = $field->uuid();
@@ -290,7 +314,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
// 'Label' defaults to the field name (mostly useful for field instances
// created in tests).
if (empty($this->label)) {
- $this->label = $this->field->name;
+ $this->label = $this->getName();
}
}
@@ -306,7 +330,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
$entity_manager = \Drupal::entityManager();
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
- $field = $this->getField();
+ $field = $this->getFieldStorageDefinition();
if ($this->isNew()) {
// Set the default instance settings.
@@ -342,7 +366,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
public function calculateDependencies() {
parent::calculateDependencies();
// Manage dependencies.
- $this->addDependency('entity', $this->getField()->getConfigDependencyName());
+ $this->addDependency('entity', $this->getFieldStorageDefinition()->getConfigDependencyName());
$bundle_entity_type_id = \Drupal::entityManager()->getDefinition($this->entity_type)->getBundleEntityType();
if ($bundle_entity_type_id != 'bundle') {
// If the target entity type uses entities to manage its bundles then
@@ -362,7 +386,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
// Invalidate the render cache for all affected entities.
$entity_manager = \Drupal::entityManager();
- $entity_type = $this->getTargetEntityTypeId();
+ $entity_type = $this->getFieldStorageDefinition()->getTargetEntityTypeId();
if ($entity_manager->hasController($entity_type, 'view_builder')) {
$entity_manager->getViewBuilder($entity_type)->resetCache();
}
@@ -413,7 +437,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
// Delete fields that have no more instances.
$fields_to_delete = array();
foreach ($instances as $instance) {
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
if (!$instance->deleted && empty($instance->noFieldDelete) && !$instance->isUninstalling() && count($field->getBundles()) == 0) {
// Key by field UUID to avoid deleting the same field twice.
$fields_to_delete[$instance->field_uuid] = $field;
@@ -450,7 +474,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
/**
* {@inheritdoc}
*/
- public function getField() {
+ public function getFieldStorageDefinition() {
if (!$this->field) {
$fields = \Drupal::entityManager()->getFieldStorageDefinitions($this->entity_type);
if (!isset($fields[$this->field_name])) {
@@ -465,25 +489,11 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return $this->field;
}
- /**
- * {@inheritdoc}
- */
- public function getName() {
- return $this->field_name;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getType() {
- return $this->getField()->getType();
- }
-
/**
* {@inheritdoc}
*/
public function getSettings() {
- return $this->settings + $this->getField()->getSettings();
+ return $this->settings + $this->getFieldStorageDefinition()->getSettings();
}
/**
@@ -494,29 +504,24 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return $this->settings[$setting_name];
}
else {
- return $this->getField()->getSetting($setting_name);
+ return $this->getFieldStorageDefinition()->getSetting($setting_name);
}
}
- /**
- * {@inheritdoc}
- */
- public function getProvider() {
- return $this->getField()->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->getFieldStorageDefinition()->isTranslatable();
}
/**
* {@inheritdoc}
*/
- public function isRevisionable() {
- return $this->getField()->isRevisionable();
+ public function setTranslatable($translatable) {
+ $this->translatable = $translatable;
+ return $this;
}
/**
@@ -560,13 +565,6 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return $this->description;
}
- /**
- * {@inheritdoc}
- */
- public function getCardinality() {
- return $this->getField()->cardinality;
- }
-
/**
* {@inheritdoc}
*/
@@ -574,13 +572,6 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return $this->required;
}
- /**
- * {@inheritdoc}
- */
- public function isMultiple() {
- return $this->getField()->isMultiple();
- }
-
/**
* {@inheritdoc}
*/
@@ -612,20 +603,6 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return array('type' => 'hidden');
}
- /**
- * {@inheritdoc}
- */
- public function getTargetEntityTypeId() {
- return $this->entity_type;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isQueryable() {
- return TRUE;
- }
-
/**
* {@inheritdoc}
*/
@@ -743,55 +720,6 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
return $this->itemDefinition;
}
- /**
- * {@inheritdoc}
- */
- public function getPropertyDefinition($name) {
- return $this->getField()->getPropertyDefinition($name);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getPropertyDefinitions() {
- return $this->getField()->getPropertyDefinitions();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getPropertyNames() {
- return $this->getField()->getPropertyNames();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getMainPropertyName() {
- return $this->getField()->getMainPropertyName();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getSchema() {
- return $this->getField()->getSchema();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getColumns() {
- return $this->getField()->getColumns();
- }
-
- /**
- * {@inheritdoc}
- */
- public function hasCustomStorage() {
- return $this->getField()->hasCustomStorage();
- }
-
/**
* {@inheritdoc}
*/
diff --git a/core/modules/field/src/FieldInstanceConfigAccessController.php b/core/modules/field/src/FieldInstanceConfigAccessController.php
index b28fd8a7d57..1146e1b1224 100644
--- a/core/modules/field/src/FieldInstanceConfigAccessController.php
+++ b/core/modules/field/src/FieldInstanceConfigAccessController.php
@@ -20,7 +20,7 @@ class FieldInstanceConfigAccessController extends EntityAccessController {
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
- if ($operation == 'delete' && $entity->getField()->isLocked()) {
+ if ($operation == 'delete' && $entity->getFieldStorageDefinition()->isLocked()) {
return FALSE;
}
return $account->hasPermission('administer ' . $entity->entity_type . ' fields');
diff --git a/core/modules/field/src/FieldInstanceConfigInterface.php b/core/modules/field/src/FieldInstanceConfigInterface.php
index 6c842825b0f..f23aaba9cd9 100644
--- a/core/modules/field/src/FieldInstanceConfigInterface.php
+++ b/core/modules/field/src/FieldInstanceConfigInterface.php
@@ -21,7 +21,7 @@ interface FieldInstanceConfigInterface extends ConfigEntityInterface, FieldDefin
* @return \Drupal\field\FieldConfigInterface
* The field entity for this instance.
*/
- public function getField();
+ public function getFieldStorageDefinition();
/**
* Allows a bundle to be renamed.
diff --git a/core/modules/field/src/FieldInstanceConfigStorage.php b/core/modules/field/src/FieldInstanceConfigStorage.php
index 8dfd30c4e77..1ca7e1c1dbc 100644
--- a/core/modules/field/src/FieldInstanceConfigStorage.php
+++ b/core/modules/field/src/FieldInstanceConfigStorage.php
@@ -132,7 +132,7 @@ class FieldInstanceConfigStorage extends ConfigEntityStorage {
$matching_instances = array();
foreach ($instances as $instance) {
// Some conditions are checked against the field.
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
// Only keep the instance if it matches all conditions.
foreach ($conditions as $key => $value) {
diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php
index d336db62782..c6785542912 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\LanguageInterface;
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;
/**
@@ -181,8 +181,8 @@ class Field extends FieldPluginBase {
$this->limit_values = FALSE;
$field_definition = $this->getFieldDefinition();
- $cardinality = $field_definition->getCardinality();
- if ($field_definition->isMultiple()) {
+ $cardinality = $field_definition->getFieldStorageDefinition()->getCardinality();
+ if ($field_definition->getFieldStorageDefinition()->isMultiple()) {
$this->multiple = TRUE;
// If "Display all values in the same row" is FALSE, then we always limit
@@ -534,7 +534,7 @@ class Field extends FieldPluginBase {
// 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;
@@ -904,8 +904,8 @@ class Field extends FieldPluginBase {
$default_langcode = language_default()->id;
$langcode = str_replace(
array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
- array($this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT), $default_langcode),
- $this->view->display_handler->options['field_language']
+ array($this->languageManager->getCurrentLanguage(LanguageInterface::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 cfc13c33a82..99be2e0fe93 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 @@ class ConfigFieldDefinitionTest extends FieldUnitTestBase {
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 a18ea9141df..819e3891f6d 100644
--- a/core/modules/field/src/Tests/FormTest.php
+++ b/core/modules/field/src/Tests/FormTest.php
@@ -8,7 +8,7 @@
namespace Drupal\field\Tests;
use Drupal\Component\Utility\String;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests field form handling.
@@ -79,7 +79,7 @@ class FormTest extends FieldTestBase {
'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 afadd265d88..b7f070864af 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 @@ class NestedFormTest extends FieldTestBase {
'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 bb1274e1046..15a49140b4d 100644
--- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
@@ -7,7 +7,7 @@
namespace Drupal\field\Tests\Views;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
@@ -52,7 +52,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
'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.
@@ -60,7 +60,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
'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_ui/src/FieldOverview.php b/core/modules/field_ui/src/FieldOverview.php
index e249eb0274a..300b31710ae 100644
--- a/core/modules/field_ui/src/FieldOverview.php
+++ b/core/modules/field_ui/src/FieldOverview.php
@@ -116,7 +116,7 @@ class FieldOverview extends OverviewBase {
// Fields.
foreach ($instances as $name => $instance) {
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
$route_parameters = array(
$this->bundleEntityType => $this->bundle,
'field_instance_config' => $instance->id(),
@@ -211,7 +211,7 @@ class FieldOverview extends OverviewBase {
// contrib modules can form_alter() the value for newly created fields.
'translatable' => array(
'#type' => 'value',
- '#value' => FALSE,
+ '#value' => TRUE,
),
);
}
@@ -381,6 +381,8 @@ class FieldOverview extends OverviewBase {
'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.
@@ -513,7 +515,7 @@ class FieldOverview extends OverviewBase {
// - locked fields,
// - fields that should not be added via user interface.
$field_type = $instance->getType();
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
if (empty($field->locked) && empty($field_types[$field_type]['no_ui'])) {
$options[$instance->getName()] = array(
'type' => $field_type,
diff --git a/core/modules/field_ui/src/Form/FieldEditForm.php b/core/modules/field_ui/src/Form/FieldEditForm.php
index 68e6849f496..aea0a64b20d 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;
@@ -77,7 +78,7 @@ class FieldEditForm extends FormBase {
$this->instance = $form_state['instance'] = $field_instance_config;
$form['#title'] = $this->instance->label();
- $field = $this->instance->getField();
+ $field = $this->instance->getFieldStorageDefinition();
$form['#field'] = $field;
$form['#bundle'] = $this->instance->bundle;
@@ -114,13 +115,13 @@ class FieldEditForm extends FormBase {
'#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 @@ class FieldEditForm extends FormBase {
$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
@@ -185,7 +187,7 @@ class FieldEditForm extends FormBase {
unset($field_values['container']);
// Merge incoming form values into the existing field.
- $field = $this->instance->getField();
+ $field = $this->instance->getFieldStorageDefinition();
foreach ($field_values as $key => $value) {
$field->{$key} = $value;
}
diff --git a/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php b/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php
index 3b995282175..3dd54c02de1 100644
--- a/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php
+++ b/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php
@@ -68,7 +68,7 @@ class FieldInstanceConfigDeleteForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state) {
- $field = $this->entity->getField();
+ $field = $this->entity->getFieldStorageDefinition();
$bundles = entity_get_bundles();
$bundle_label = $bundles[$this->entity->entity_type][$this->entity->bundle]['label'];
diff --git a/core/modules/field_ui/src/Form/FieldInstanceEditForm.php b/core/modules/field_ui/src/Form/FieldInstanceEditForm.php
index 9c4de60f7c8..7ac1affb4b9 100644
--- a/core/modules/field_ui/src/Form/FieldInstanceEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldInstanceEditForm.php
@@ -67,7 +67,7 @@ class FieldInstanceEditForm extends FormBase {
$bundle = $this->instance->bundle;
$entity_type = $this->instance->entity_type;
- $field = $this->instance->getField();
+ $field = $this->instance->getFieldStorageDefinition();
$bundles = entity_get_bundles();
$form_title = $this->t('%instance settings for %bundle', array(
diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
index 4d3625b45fd..d22030d4341 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\LanguageInterface;
use Drupal\Component\Utility\String;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldInstanceConfig;
@@ -212,12 +212,12 @@ class ManageFieldsTest extends FieldUiTestBase {
// 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/file.field.inc b/core/modules/file/file.field.inc
index 75d7160a749..68a0f00e122 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -215,7 +215,7 @@ function template_preprocess_file_upload_help(&$variables) {
* fid, FALSE if it does not.
*/
function file_field_find_file_reference_column(FieldDefinitionInterface $field) {
- $schema = $field->getSchema();
+ $schema = $field->getFieldStorageDefinition()->getSchema();
foreach ($schema['foreign keys'] as $data) {
if ($data['table'] == 'file_managed') {
foreach ($data['columns'] as $field_column => $column) {
diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
index 4fa4e04d81c..b9b900ff2e0 100644
--- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
+++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
@@ -8,10 +8,10 @@
namespace Drupal\file\Plugin\Field\FieldWidget;
use Drupal\Component\Utility\String;
-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;
/**
@@ -82,9 +82,9 @@ class FileWidget extends WidgetBase {
}
// Determine the number of widgets to display.
- $cardinality = $this->fieldDefinition->getCardinality();
+ $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
switch ($cardinality) {
- case FieldDefinitionInterface::CARDINALITY_UNLIMITED:
+ case FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED:
$max = count($items);
$is_multiple = TRUE;
break;
@@ -131,7 +131,7 @@ class FileWidget extends WidgetBase {
}
$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.
@@ -198,7 +198,7 @@ class FileWidget extends WidgetBase {
'description_field' => NULL,
);
- $cardinality = $this->fieldDefinition->getCardinality();
+ $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
$defaults = array(
'fids' => array(),
'display' => (bool) $field_settings['display_default'],
diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php
index 219c083f5e6..674fa8e8166 100644
--- a/core/modules/file/src/Tests/FileFieldDisplayTest.php
+++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php
@@ -7,7 +7,7 @@
namespace Drupal\file\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Tests that formatters are working properly.
@@ -31,7 +31,7 @@ class FileFieldDisplayTest extends FileFieldTestBase {
$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 d35a491c37a..bab0f11c4d1 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 @@ class FileFieldValidateTest extends FileFieldTestBase {
// 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 ea3ba4ade2b..c4fd4b4574e 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 @@ class FileItemTest extends FieldUnitTestBase {
'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/hal/src/Tests/NormalizerTestBase.php b/core/modules/hal/src/Tests/NormalizerTestBase.php
index da9200a147e..8bb477726b0 100644
--- a/core/modules/hal/src/Tests/NormalizerTestBase.php
+++ b/core/modules/hal/src/Tests/NormalizerTestBase.php
@@ -85,12 +85,12 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
'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 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
'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 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
'name' => 'field_test_entity_reference',
'entity_type' => 'entity_test',
'type' => 'entity_reference',
- 'translatable' => TRUE,
'settings' => array(
'target_type' => 'entity_test',
),
@@ -120,6 +119,7 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
'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/image.module b/core/modules/image/image.module
index c951dcf7700..f620c0132ea 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -361,7 +361,7 @@ function image_entity_presave(EntityInterface $entity) {
$field = FALSE;
$entity_type_id = $entity->getEntityTypeId();
if ($entity_type_id == 'field_instance_config') {
- $field = $entity->getField();
+ $field = $entity->getFieldStorageDefinition();
$default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultInstanceSettings('image');
}
elseif ($entity_type_id == 'field_config') {
@@ -440,7 +440,7 @@ function image_field_config_update(FieldConfigInterface $field) {
* Implements hook_ENTITY_TYPE_update() for 'field_instance_config'.
*/
function image_field_instance_config_update(FieldInstanceConfigInterface $field_instance) {
- $field = $field_instance->getField();
+ $field = $field_instance->getFieldStorageDefinition();
if ($field->type != 'image') {
// Only act on image fields.
return;
@@ -494,7 +494,7 @@ function image_field_config_delete(FieldConfigInterface $field) {
* Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'.
*/
function image_field_instance_config_delete(FieldInstanceConfigInterface $field_instance) {
- $field = $field_instance->getField();
+ $field = $field_instance->getFieldStorageDefinition();
if ($field->type != 'image') {
// Only act on image fields.
return;
diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php
index 9378441f45a..e99d8ebd933 100644
--- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php
@@ -29,7 +29,7 @@ abstract class ImageFormatterBase extends FileFormatterBase {
// 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 FieldInstanceConfigInterface) {
- $default_image = $this->fieldDefinition->getField()->getSetting('default_image');
+ $default_image = $this->fieldDefinition->getFieldStorageDefinition()->getSetting('default_image');
}
if (!empty($default_image['fid']) && ($file = file_load($default_image['fid']))) {
diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
index 49d2e25894d..c2e8737d5ef 100644
--- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
+++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
@@ -158,7 +158,7 @@ class ImageItem extends FileItem {
// 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()->getSettings();
+ $settings = $this->getFieldDefinition()->getFieldStorageDefinition()->getSettings();
$scheme_options = array();
foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) {
diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
index 94481c0fd34..0ba9e7e8cb2 100644
--- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -85,7 +85,7 @@ class ImageWidget extends FileWidget {
protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) {
$elements = parent::formMultipleElements($items, $form, $form_state);
- $cardinality = $this->fieldDefinition->getCardinality();
+ $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
$file_upload_help = array(
'#theme' => 'file_upload_help',
'#description' => '',
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index 54be792579e..f4626a4fd65 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -77,7 +77,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$instance_field_settings = $instance->getSettings();
$this->assertEqual($instance_field_settings['default_image']['fid'], $default_images['instance']->id());
- $field = $instance->getField();
+ $field = $instance->getFieldStorageDefinition();
// The field default image id should be 1.
$default_image = $field->getSetting('default_image');
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index 271e9f7bb93..5058d2fa5d6 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;
/**
@@ -236,7 +236,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$field_name . '[0][title]' => $this->randomName($test_size),
);
$this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published'));
- $schema = $instance->getField()->getSchema();
+ $schema = $instance->getFieldStorageDefinition()->getSchema();
$this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array(
'%max' => $schema['columns']['alt']['length'],
'%length' => $test_size,
@@ -253,7 +253,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// 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 e17987b14e3..53472a81638 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 @@ class ImageItemTest extends FieldUnitTestBase {
'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 fb83895f36a..64bfdf165eb 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 @@ class ImageThemeFunctionTest extends WebTestBase {
'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/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
index ad749fbb3a1..4541ba55d13 100644
--- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
+++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
@@ -103,7 +103,7 @@ class LinkWidget extends WidgetBase {
// If cardinality is 1, ensure a label is output for the field by wrapping it
// in a details element.
- if ($this->fieldDefinition->getCardinality() == 1) {
+ if ($this->fieldDefinition->getFieldStorageDefinition()->getCardinality() == 1) {
$element += array(
'#type' => 'fieldset',
);
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 13c2ec83727..df3abbf7f2a 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
@@ -133,7 +133,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/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php
index 165bc92d0eb..01e7688f624 100644
--- a/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php
@@ -47,7 +47,7 @@ abstract class OptionsWidgetBase extends WidgetBase {
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
- $property_names = $this->fieldDefinition->getPropertyNames();
+ $property_names = $this->fieldDefinition->getFieldStorageDefinition()->getPropertyNames();
$this->column = $property_names[0];
}
@@ -58,7 +58,7 @@ abstract class OptionsWidgetBase extends WidgetBase {
// Prepare some properties for the child methods to build the actual form
// element.
$this->required = $element['#required'];
- $this->multiple = $this->fieldDefinition->isMultiple();
+ $this->multiple = $this->fieldDefinition->getFieldStorageDefinition()->isMultiple();
$this->has_value = isset($items[0]->{$this->column});
// Add our custom validator.
diff --git a/core/modules/path/src/Tests/PathLanguageTest.php b/core/modules/path/src/Tests/PathLanguageTest.php
index 26486929433..958b4e87c47 100644
--- a/core/modules/path/src/Tests/PathLanguageTest.php
+++ b/core/modules/path/src/Tests/PathLanguageTest.php
@@ -61,9 +61,6 @@ class PathLanguageTest extends PathTestBase {
// Enable translation for page node.
$edit = array(
'entity_types[node]' => 1,
- 'settings[node][article][translatable]' => 1,
- 'settings[node][article][fields][path]' => 1,
- 'settings[node][article][fields][body]' => 1,
'settings[node][page][translatable]' => 1,
'settings[node][page][fields][path]' => 1,
'settings[node][page][fields][body]' => 1,
@@ -71,8 +68,9 @@ class PathLanguageTest extends PathTestBase {
);
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save'));
- $field = FieldConfig::loadByName('node', 'body');
- $this->assertTrue($field->isTranslatable(), 'Node body is translatable.');
+ $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'page');
+ $this->assertTrue($definitions['path']->isTranslatable(), 'Node path is translatable.');
+ $this->assertTrue($definitions['body']->isTranslatable(), 'Node body is translatable.');
}
/**
@@ -81,7 +79,6 @@ class PathLanguageTest extends PathTestBase {
function testAliasTranslation() {
$english_node = $this->drupalCreateNode(array('type' => 'page', 'langcode' => 'en'));
$english_alias = $this->randomName();
- $translatable = !$english_node->isNew() && $english_node->isTranslatable() && count($english_node->getTranslationLanguages()) > 1 && ($field = $english_node->getFieldDefinition('status')) && $field->isTranslatable();
// Edit the node to set language and path.
$edit = array();
@@ -101,7 +98,7 @@ class PathLanguageTest extends PathTestBase {
$edit['body[0][value]'] = $this->randomName();
$french_alias = $this->randomName();
$edit['path[0][alias]'] = $french_alias;
- $this->drupalPostForm(NULL, $edit, t('Save') . ' ' . ($translatable ? t('(this translation)') : t('(all translations)')));
+ $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
// Clear the path lookup cache.
$this->container->get('path.alias_manager')->cacheClear();
diff --git a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
index a904553e4cd..3938ce90f9d 100644
--- a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
+++ b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
@@ -29,7 +29,7 @@ class PlainTextEditor extends InPlaceEditorBase {
$field_definition = $items->getFieldDefinition();
// This editor is incompatible with multivalued fields.
- if ($field_definition->getCardinality() != 1) {
+ if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) {
return FALSE;
}
// This editor is incompatible with processed ("rich") text fields.
diff --git a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
index 9bee3e1ccf7..1e2f8388982 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\LanguageInterface;
use Drupal\simpletest\WebTestBase;
@@ -85,7 +85,7 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
'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/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php
index fdc2d091d84..21c88b493d9 100644
--- a/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php
+++ b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php
@@ -27,7 +27,7 @@ class WysiwygEditor extends InPlaceEditorBase {
$field_definition = $items->getFieldDefinition();
// This editor is incompatible with multivalued fields.
- if ($field_definition->getCardinality() != 1) {
+ if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) {
return FALSE;
}
// This editor is compatible with processed ("rich") text fields; but only
diff --git a/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php b/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php
index 8b59536fed4..ed49cfcce75 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\LanguageInterface;
@@ -63,7 +64,7 @@ class TaxonomyTermReferenceRdfaTest extends FieldRdfaTestBase {
'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 82b8516ff64..2c84d0f723c 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 @@ class TaxonomyTermFieldAttributesTest extends TaxonomyTestBase {
'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 ee76e9f0aff..463a9a09c8b 100644
--- a/core/modules/shortcut/src/Entity/Shortcut.php
+++ b/core/modules/shortcut/src/Entity/Shortcut.php
@@ -203,7 +203,8 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface {
$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 5eb13e58a56..dfbc4237501 100644
--- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php
+++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
@@ -7,7 +7,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 +40,7 @@ class MultiFormTest extends AjaxTestBase {
'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 5d65632f933..3f73b43e14f 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\Component\Utility\NestedArray;
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;
/**
@@ -162,7 +162,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
'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/EntityFieldTest.php b/core/modules/system/src/Tests/Entity/EntityFieldTest.php
index 91cbacbcf6b..b6859dc714b 100644
--- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php
@@ -399,7 +399,7 @@ class EntityFieldTest extends EntityUnitTestBase {
$this->assertEqual($userref_properties['target_id']->getDataType(), 'integer', $entity_type .': Entity id property of the user found.');
$this->assertEqual($userref_properties['entity']->getDataType(), 'entity_reference', $entity_type .': Entity reference property of the user found.');
- $textfield_properties = $entity->field_test_text->getFieldDefinition()->getPropertyDefinitions();
+ $textfield_properties = $entity->field_test_text->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinitions();
$this->assertEqual($textfield_properties['value']->getDataType(), 'string', $entity_type .': String value property of the test-text field found.');
$this->assertEqual($textfield_properties['format']->getDataType(), 'filter_format', $entity_type .': String format field of the test-text field found.');
$this->assertEqual($textfield_properties['processed']->getDataType(), 'string', $entity_type .': String processed property of the test-text field found.');
diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
index c76fc978227..3be40c6caa7 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 @@ abstract class EntityLanguageTestBase extends EntityUnitTestBase {
'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 @@ abstract class EntityLanguageTestBase extends EntityUnitTestBase {
'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 @@ abstract class EntityLanguageTestBase extends EntityUnitTestBase {
* @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 ef08f1787b7..5ea3ef9c4bf 100644
--- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php
+++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php
@@ -55,7 +55,7 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase {
// 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 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase {
// 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 1f91e807078..f8cd8b06112 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 @@ class RebuildTest extends WebTestBase {
'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 015b06765e3..162f7ea081b 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/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php
index 60328615406..8796e831243 100644
--- a/core/modules/taxonomy/src/Entity/Term.php
+++ b/core/modules/taxonomy/src/Entity/Term.php
@@ -11,8 +11,6 @@ use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldDefinition;
-use Drupal\Core\Field\FieldStorageDefinitionInterface;
-use Drupal\Core\TypedData\DataDefinition;
use Drupal\taxonomy\TermInterface;
/**
@@ -163,7 +161,7 @@ class Term extends ContentEntityBase implements TermInterface {
$fields['parent'] = FieldDefinition::create('integer')
->setLabel(t('Term Parents'))
->setDescription(t('The parents of this term.'))
- ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
+ ->setCardinality(FieldDefinition::CARDINALITY_UNLIMITED)
// Save new terms with no parents by default.
->setDefaultValue(0)
->setSetting('unsigned', TRUE)
diff --git a/core/modules/taxonomy/src/Tests/LegacyTest.php b/core/modules/taxonomy/src/Tests/LegacyTest.php
index c7035c9fd6d..bf7ae23ed25 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 @@ class LegacyTest extends TaxonomyTestBase {
'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 31031274f25..f947600def4 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 @@ class RssTest extends TaxonomyTestBase {
'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 c74460c74ba..4f3b3841675 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\LanguageInterface;
use Drupal\field\Tests\FieldUnitTestBase;
@@ -55,7 +55,7 @@ class TaxonomyTermReferenceItemTest extends FieldUnitTestBase {
'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 8ec55e7e5d9..cfe29f9a575 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 @@ class TermFieldMultipleVocabularyTest extends TaxonomyTestBase {
'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 e79d159a638..ce4c8fd7fe1 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 @@ class TermIndexTest extends TaxonomyTestBase {
'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 @@ class TermIndexTest extends TaxonomyTestBase {
'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 d309e300857..e08cf24438c 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 @@ class TermTest extends TaxonomyTestBase {
'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 caf23c45421..241883b6d36 100644
--- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php
@@ -7,9 +7,9 @@
namespace Drupal\taxonomy\Tests;
-use Drupal\Component\Utility\Xss;
-use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\Xss;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Test taxonomy token replacement in strings.
@@ -34,7 +34,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
'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 587f4cee06c..aee659b55e3 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\LanguageInterface;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
@@ -83,7 +83,7 @@ abstract class TaxonomyTestBase extends ViewTestBase {
'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 d6cfe967ccb..3acb5b49a5c 100644
--- a/core/modules/user/src/Entity/User.php
+++ b/core/modules/user/src/Entity/User.php
@@ -8,11 +8,10 @@
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\user\UserInterface;
/**
@@ -530,7 +529,7 @@ class User extends ContentEntityBase implements UserInterface {
$fields['roles'] = FieldDefinition::create('string')
->setCustomStorage(TRUE)
->setLabel(t('Roles'))
- ->setCardinality(FieldDefinitionInterface::CARDINALITY_UNLIMITED)
+ ->setCardinality(FieldDefinition::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 0a6916ca87f..faa9c7cf431 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -7,7 +7,7 @@
namespace Drupal\user\Tests;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
@@ -253,7 +253,7 @@ class UserRegistrationTest extends WebTestBase {
$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 cecfcc1e715..d0e325085c0 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 @@ abstract class DisplayPluginBase extends PluginBase {
$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 @@ abstract class DisplayPluginBase extends PluginBase {
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 40f231a0413..47fedaa4609 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 @@ class TaggedWithTest extends WizardTestBase {
'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/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
index 80c0b88354b..49efb6688b2 100644
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
@@ -248,7 +248,7 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
),
);
- $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));
@@ -366,7 +366,7 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
$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())
@@ -502,11 +502,11 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
$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())
@@ -627,7 +627,7 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
$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))
@@ -809,11 +809,11 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
$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 d620399953d..abf8505b695 100644
--- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
@@ -9,7 +9,7 @@ namespace Drupal\Tests\Core\Entity;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Field\FieldDefinition;
-use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Tests\UnitTestCase;
/**
@@ -192,8 +192,8 @@ class FieldDefinitionTest extends UnitTestCase {
$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 8fac217b35d..0b91716f892 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Schema/ContentEntitySchemaHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Schema/ContentEntitySchemaHandlerTest.php
@@ -788,7 +788,7 @@ class ContentEntitySchemaHandlerTest extends UnitTestCase {
* 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');