Commit 1476c56c authored by webchick's avatar webchick

Issue #2312093 by alexpott, yched, andypost, swentel | xjm: Rename...

Issue #2312093 by alexpott, yched, andypost, swentel | xjm: Rename FieldInstanceConfig to FieldConfig.
parent 7fa6684f
......@@ -374,7 +374,7 @@ field_config_base:
type: string
label: 'Default value function'
settings:
type: field.[%parent.field_type].instance_settings
type: field.[%parent.field_type].field_settings
third_party_settings:
type: sequence
label: 'Third party settings'
......@@ -410,7 +410,7 @@ core.date_format.*:
# Schema for the String field type.
field.string.instance_settings:
field.string.field_settings:
type: sequence
label: 'String settings'
sequence:
......@@ -430,7 +430,7 @@ field.string.value:
# Schema for the configuration files of the Boolean field type.
field.boolean.settings:
field.boolean.storage_settings:
type: mapping
label: 'Boolean settings'
mapping:
......@@ -441,7 +441,7 @@ field.boolean.settings:
type: string
label: 'Off label'
field.boolean.instance_settings:
field.boolean.field_settings:
label: 'Boolean settings'
type: mapping
mapping: { }
......@@ -459,13 +459,13 @@ field.boolean.value:
# Schema for the configuration files of the Email field type.
field.email.settings:
field.email.storage_settings:
type: sequence
label: 'Email settings'
sequence:
- type: string
field.email.instance_settings:
field.email.field_settings:
type: sequence
label: 'Email settings'
sequence:
......@@ -485,14 +485,14 @@ field.email.value:
# Schema for configuration files of a numeric field types.
field.integer.settings:
field.integer.storage_settings:
type: sequence
label: 'Integer settings'
sequence:
- type: string
label: 'setting'
field.integer.instance_settings:
field.integer.field_settings:
type: mapping
label: 'Integer'
mapping:
......@@ -520,7 +520,7 @@ field.integer.value:
type: integer
label: 'Value'
field.decimal.settings:
field.decimal.storage_settings:
type: mapping
label: 'Decimal settings'
mapping:
......@@ -531,7 +531,7 @@ field.decimal.settings:
type: integer
label: 'Scale'
field.decimal.instance_settings:
field.decimal.field_settings:
type: mapping
label: 'Decimal'
mapping:
......@@ -559,14 +559,14 @@ field.decimal.value:
type: float
label: 'Value'
field.float.settings:
field.float.storage_settings:
type: sequence
label: 'Float settings'
sequence:
- type: string
label: 'setting'
field.float.instance_settings:
field.float.field_settings:
type: mapping
label: 'Float'
mapping:
......
......@@ -822,7 +822,7 @@ protected function checkOp($collection, $op, $name) {
// result of a secondary configuration write. Change the operation
// into an update. This is the desired behavior since renames often
// have to occur together. For example, renaming a node type must
// also result in renaming its field instances and entity displays.
// also result in renaming its fields and entity displays.
$this->storageComparer->moveRenameToUpdate($name);
return FALSE;
}
......
......@@ -215,8 +215,8 @@ public function uninstall($type, $name) {
// dependencies on the to-be-removed entities.
$extension_dependent_entities = $this->findConfigEntityDependentsAsEntities($type, array($name));
// Reverse the array to that entities are removed in the correct order of
// dependence. For example, this ensures that field instances are removed
// before fields.
// dependence. For example, this ensures that fields are removed before
// field storages.
foreach (array_reverse($extension_dependent_entities) as $extension_dependent_entity) {
$extension_dependent_entity->setUninstalling(TRUE);
$extension_dependent_entity->delete();
......
......@@ -16,8 +16,8 @@
* Configuration entities can depend on modules, themes and other configuration
* entities. The dependency system is used during configuration installation to
* ensure that configuration entities are imported in the correct order. For
* example, node types are created before their fields and the fields are
* created before their field instances.
* example, node types are created before their field storages and the field
* storages are created before their fields.
*
* Dependencies are stored to the configuration entity's configuration object so
* that they can be checked without the module that provides the configuration
......
......@@ -219,8 +219,8 @@ public function createChangelist() {
* Creates the delete changelist.
*
* The list of deletes is sorted so that dependencies are deleted after
* configuration entities that depend on them. For example, field instances
* should be deleted after fields.
* configuration entities that depend on them. For example, fields should be
* deleted after field storages.
*
* @param string $collection
* The storage collection to operate on.
......@@ -234,8 +234,8 @@ protected function addChangelistDelete($collection) {
* Creates the create changelist.
*
* The list of creates is sorted so that dependencies are created before
* configuration entities that depend on them. For example, fields
* should be created before field instances.
* configuration entities that depend on them. For example, field storages
* should be created before fields.
*
* @param string $collection
* The storage collection to operate on.
......@@ -249,8 +249,8 @@ protected function addChangelistCreate($collection) {
* Creates the update changelist.
*
* The list of updates is sorted so that dependencies are created before
* configuration entities that depend on them. For example, fields
* should be updated before field instances.
* configuration entities that depend on them. For example, field storages
* should be updated before fields.
*
* @param string $collection
* The storage collection to operate on.
......
......@@ -10,8 +10,6 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Cache\Cache;
use Drupal\field\FieldInstanceConfigInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ContentEntityStorageBase extends EntityStorageBase implements FieldableEntityStorageInterface {
......@@ -137,7 +135,7 @@ public function purgeFieldData(FieldDefinitionInterface $field_definition, $batc
* Reads values to be purged for a single field.
*
* This method is called during field data purge, on fields for which
* onFieldDelete() or onFieldInstanceDelete() has previously run.
* onFieldDelete() or onFieldDelete() has previously run.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The field definition.
......
......@@ -64,7 +64,7 @@ interface EntityFormDisplayInterface extends EntityDisplayInterface {
* // One sub-array per copy of the widget, keyed by delta.
* 0 => array(
* '#title' => The title to be displayed by the widget,
* '#description' => The description text for the field instance,
* '#description' => The description text for the field,
* '#required' => Whether the widget should be marked required,
* '#delta' => 0,
* '#weight' => 0,
......
......@@ -11,8 +11,8 @@
use Drupal\Core\Config\Entity\ThirdPartySettingsTrait;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Entity\Display\EntityDisplayInterface;
use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\field\FieldInstanceConfigInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldConfigInterface;
/**
* Provides a common base class for entity view and form displays.
......@@ -171,9 +171,9 @@ public function calculateDependencies() {
// Create dependencies on both hidden and visible fields.
$fields = $this->content + $this->hidden;
foreach ($fields as $field_name => $component) {
$field_instance = FieldInstanceConfig::loadByName($this->targetEntityType, $this->bundle, $field_name);
if ($field_instance) {
$this->addDependency('entity', $field_instance->getConfigDependencyName());
$field = FieldConfig::loadByName($this->targetEntityType, $this->bundle, $field_name);
if ($field) {
$this->addDependency('entity', $field->getConfigDependencyName());
}
// Create a dependency on the module that provides the formatter or
// widget.
......@@ -373,7 +373,7 @@ protected function getFieldDefinitions() {
* Determines if a field has options for a given display.
*
* @param FieldDefinitionInterface $definition
* A field instance definition.
* A field definition.
* @return array|null
*/
private function fieldHasDisplayOptions(FieldDefinitionInterface $definition) {
......@@ -388,7 +388,7 @@ private function fieldHasDisplayOptions(FieldDefinitionInterface $definition) {
public function onDependencyRemoval(array $dependencies) {
$changed = FALSE;
foreach ($dependencies['entity'] as $entity) {
if ($entity instanceof FieldInstanceConfigInterface) {
if ($entity instanceof FieldConfigInterface) {
// Remove components for fields that are being deleted.
$this->removeComponent($entity->getName());
unset($this->hidden[$entity->getName()]);
......
......@@ -109,7 +109,7 @@ public function resetCache(array $entities = NULL);
* @param array $display_options
* Can be either:
* - The name of a view mode. The field will be displayed according to the
* display settings specified for this view mode in the $instance
* display settings specified for this view mode in the $field
* definition for the field in the entity's bundle. If no display settings
* are found for the view mode, the settings for the 'default' view mode
* will be used.
......
......@@ -1554,7 +1554,7 @@ public function onBundleRename($bundle, $bundle_new) {
// configurable fields, so we use the specific API.
// @todo Use the unified store of deleted field definitions instead in
// https://www.drupal.org/node/2282119
$field_definitions += entity_load_multiple_by_properties('field_instance_config', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'deleted' => TRUE, 'include_deleted' => TRUE));
$field_definitions += entity_load_multiple_by_properties('field_config', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'deleted' => TRUE, 'include_deleted' => TRUE));
$table_mapping = $this->getTableMapping();
foreach ($field_definitions as $field_definition) {
......
......@@ -939,8 +939,8 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
$entity_manager = \Drupal::entityManager();
foreach ($module_list as $module) {
// Clean up all entity bundles (including field instances) of every entity
// type provided by the module that is being uninstalled.
// Clean up all entity bundles (including fields) of every entity type
// provided by the module that is being uninstalled.
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->getProvider() == $module) {
foreach (array_keys($entity_manager->getBundleInfo($entity_type_id)) as $bundle) {
......
......@@ -76,7 +76,7 @@ class FieldWidget extends Plugin {
/**
* An integer to determine the weight of this widget relative to other widgets
* in the Field UI when selecting a widget for a given field instance.
* in the Field UI when selecting a widget for a given field.
*
* @var int optional
*/
......
......@@ -62,7 +62,7 @@ public static function create($type) {
// settings for the field type.
// @todo Cleanup in https://drupal.org/node/2116341.
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$default_settings = $field_type_manager->getDefaultSettings($type) + $field_type_manager->getDefaultInstanceSettings($type);
$default_settings = $field_type_manager->getDefaultStorageSettings($type) + $field_type_manager->getDefaultFieldSettings($type);
$field_definition->itemDefinition->setSettings($default_settings);
return $field_definition;
}
......
......@@ -155,7 +155,7 @@ protected function getBaseFieldDefinition() {
*/
public function preSave(EntityStorageInterface $storage) {
// Set the default instance settings.
$this->settings += \Drupal::service('plugin.manager.field.field_type')->getDefaultInstanceSettings($this->getType());
$this->settings += \Drupal::service('plugin.manager.field.field_type')->getDefaultFieldSettings($this->getType());
// Call the parent's presave method to perform validate and calculate
// dependencies.
......
......@@ -21,7 +21,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
use ThirdPartySettingsTrait;
/**
* The instance ID.
* The field ID.
*
* The ID consists of 3 parts: the entity type, bundle and the field name.
*
......@@ -32,7 +32,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
public $id;
/**
* The name of the field attached to the bundle by this instance.
* The name of the field attached to the bundle by this field.
*
* @var string
*/
......@@ -52,38 +52,38 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
public $field_type;
/**
* The name of the entity type the instance is attached to.
* The name of the entity type the field is attached to.
*
* @var string
*/
public $entity_type;
/**
* The name of the bundle the instance is attached to.
* The name of the bundle the field is attached to.
*
* @var string
*/
public $bundle;
/**
* The human-readable label for the instance.
* The human-readable label for the field.
*
* This will be used as the title of Form API elements for the field in entity
* edit forms, or as the label for the field values in displayed entities.
*
* If not specified, this defaults to the field_name (mostly useful for field
* instances created in tests).
* If not specified, this defaults to the field_name (mostly useful for fields
* created in tests).
*
* @var string
*/
public $label;
/**
* The instance description.
* The field description.
*
* A human-readable description for the field when used with this bundle.
* For example, the description will be the help text of Form API elements for
* this instance in entity edit forms.
* this field in entity edit forms.
*
* @var string
*/
......
......@@ -18,7 +18,7 @@
* to ensure that implementations have the expected save() method.
*
* @see \Drupal\Core\Field\Entity\BaseFieldOverride
* @see \Drupal\field\Entity\FieldInstanceConfig
* @see \Drupal\field\Entity\FieldConfig
*/
interface FieldConfigInterface extends FieldDefinitionInterface, ConfigEntityInterface, ThirdPartySettingsInterface {
......@@ -52,10 +52,10 @@ public function setTranslatable($translatable);
public function allowBundleRename();
/**
* Returns the name of the bundle this field instance is attached to.
* Returns the name of the bundle this field is attached to.
*
* @return string
* The name of the bundle this field instance is attached to.
* The name of the bundle this field is attached to.
*/
public function targetBundle();
......
......@@ -28,7 +28,7 @@ abstract class FieldConfigStorageBase extends ConfigEntityStorage {
protected function mapFromStorageRecords(array $records) {
foreach ($records as &$record) {
$class = $this->fieldTypeManager->getPluginClass($record['field_type']);
$record['settings'] = $class::instanceSettingsFromConfigData($record['settings']);
$record['settings'] = $class::fieldSettingsFromConfigData($record['settings']);
}
return parent::mapFromStorageRecords($records);
}
......@@ -39,7 +39,7 @@ protected function mapFromStorageRecords(array $records) {
protected function mapToStorageRecord(EntityInterface $entity) {
$record = parent::mapToStorageRecord($entity);
$class = $this->fieldTypeManager->getPluginClass($record['field_type']);
$record['settings'] = $class::instanceSettingsToConfigData($record['settings']);
$record['settings'] = $class::fieldSettingsFromConfigData($record['settings']);
return $record;
}
......
......@@ -28,16 +28,16 @@
* information comes from. For example, field.module provides an implementation
* based on two levels of configuration. It allows the site administrator to add
* custom fields to any entity type and bundle via the "field_storage_config"
* and "field_instance_config" configuration entities. The former for storing
* and "field_config" configuration entities. The former for storing
* configuration that is independent of which entity type and bundle the field
* is added to, and the latter for storing configuration that is specific to the
* entity type and bundle. The class that implements "field_instance_config"
* entity type and bundle. The class that implements "field_config"
* configuration entities also implements this interface, returning information
* from either itself, or from the corresponding "field_storage_config"
* configuration, as appropriate.
*
* However, entity base fields, such as $node->title, are not managed by
* field.module and its "field_storage_config"/"field_instance_config"
* field.module and its "field_storage_config"/"field_config"
* configuration entities. Therefore, their definitions are provided by
* different objects based on the class \Drupal\Core\Field\BaseFieldDefinition,
* which implements this interface as well.
......
......@@ -28,14 +28,14 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
public static function defaultStorageSettings() {
return array();
}
/**
* {@inheritdoc}
*/
public static function defaultInstanceSettings() {
public static function defaultFieldSettings() {
return array();
}
......@@ -250,42 +250,42 @@ public function deleteRevision() { }
/**
* {@inheritdoc}
*/
public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) {
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
return array();
}
/**
* {@inheritdoc}
*/
public function instanceSettingsForm(array $form, FormStateInterface $form_state) {
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
return array();
}
/**
* {@inheritdoc}
*/
public static function settingsToConfigData(array $settings) {
public static function storageSettingsToConfigData(array $settings) {
return $settings;
}
/**
* {@inheritdoc}
*/
public static function settingsFromConfigData(array $settings) {
public static function storageSettingsFromConfigData(array $settings) {
return $settings;
}
/**
* {@inheritdoc}
*/
public static function instanceSettingsToConfigData(array $settings) {
public static function fieldSettingsToConfigData(array $settings) {
return $settings;
}
/**
* {@inheritdoc}
*/
public static function instanceSettingsFromConfigData(array $settings) {
public static function fieldSettingsFromConfigData(array $settings) {
return $settings;
}
......
......@@ -55,7 +55,7 @@ public static function mainPropertyName();
*
* This method is static because the field schema information is needed on
* creation of the field. FieldItemInterface objects instantiated at that
* time are not reliable as field instance settings might be missing.
* time are not reliable as field settings might be missing.
*
* Computed fields having no schema should return an empty array.
*
......@@ -231,20 +231,20 @@ public function deleteRevision();
public static function generateSampleValue(FieldDefinitionInterface $field_definition);
/**
* Defines the field-level settings for this plugin.
* Defines the storage-level settings for this plugin.
*
* @return array
* A list of default settings, keyed by the setting name.
*/
public static function defaultSettings();
public static function defaultStorageSettings();
/**
* Defines the instance-level settings for this plugin.
* Defines the field-level settings for this plugin.
*
* @return array
* A list of default settings, keyed by the setting name.
*/
public static function defaultInstanceSettings();
public static function defaultFieldSettings();
/**
* Returns a settings array that can be stored as a configuration value.
......@@ -278,12 +278,12 @@ public static function defaultInstanceSettings();
*
* @see \Drupal\Core\Config\Config::set()
*/
public static function settingsToConfigData(array $settings);
public static function storageSettingsToConfigData(array $settings);
/**
* Returns a settings array in the field type's canonical representation.
*
* This function does the inverse of static::settingsToConfigData(). It's
* This function does the inverse of static::storageSettingsToConfigData(). It's
* called when loading a field's settings from a configuration object.
*
* @param array $settings
......@@ -293,58 +293,56 @@ public static function settingsToConfigData(array $settings);
* The settings, in the representation expected by the field type and code
* that interacts with it.
*
* @see \Drupal\Core\Field\FieldItemInterface::settingsToConfigData()
* @see \Drupal\Core\Field\FieldItemInterface::storageSettingsToConfigData()
*/
public static function settingsFromConfigData(array $settings);
public static function storageSettingsFromConfigData(array $settings);
/**
* Returns a settings array that can be stored as a configuration value.
*
* Same as static::settingsToConfigData(), but for the field's instance
* settings.
* Same as static::storageSettingsToConfigData(), but for the field's settings.
*
* @param array $settings
* The field's instance settings in the field type's canonical
* representation.
* The field's settings in the field type's canonical representation.
*
* @return array
* An array (either the unmodified $settings or a modified representation)
* that is suitable for storing as a deployable configuration value.
*
* @see \Drupal\Core\Field\FieldItemInterface::settingsToConfigData()
* @see \Drupal\Core\Field\FieldItemInterface::storageSettingsToConfigData()
*/
public static function instanceSettingsToConfigData(array $settings);
public static function fieldSettingsToConfigData(array $settings);
/**
* Returns a settings array in the field type's canonical representation.
*
* This function does the inverse of static::instanceSettingsToConfigData().
* It's called when loading a field's instance settings from a configuration
* This function does the inverse of static::fieldSettingsToConfigData().
* It's called when loading a field's settings from a configuration
* object.
*
* @param array $settings
* The field's instance settings, as it is stored within a configuration
* The field's settings, as it is stored within a configuration
* object.
*
* @return array
* The instance settings, in the representation expected by the field type