diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldType.php b/core/lib/Drupal/Core/Field/Annotation/FieldType.php index 13feaae..3b306c9 100644 --- a/core/lib/Drupal/Core/Field/Annotation/FieldType.php +++ b/core/lib/Drupal/Core/Field/Annotation/FieldType.php @@ -52,23 +52,6 @@ class FieldType extends DataType { public $description; /** - * An array of instance-level settings available for the field type. - * - * Keys are the names of the settings, and values are the default values for - * those settings. - * - * Instance-level settings can have different values on each field instance, - * and thus allow greater flexibility than field-level settings. It is - * recommended to put settings at the instance level whenever possible. - * Notable exceptions: settings acting on the storage schema, or settings that - * Views needs to use across field instances (for example, settings defining - * the list of allowed values for the field). - * - * @var array - */ - public $instance_settings; - - /** * The plugin_id of the default widget for this field type. * * This widget must be available whenever the field type is available (i.e. diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 5802b4a..cff21f1 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -33,6 +33,13 @@ public static function settings() { /** * {@inheritdoc} */ + public static function instanceSettings() { + return array(); + } + + /** + * {@inheritdoc} + */ public static function mainPropertyName() { return 'value'; } diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index 579f0d4..94f71b7 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -221,6 +221,14 @@ public function deleteRevision(); public static function settings(); /** + * Defines the instance-level settings for this plugin. + * + * @return array + * A list of default settings, keyed by the setting name. + */ + public static function instanceSettings(); + + /** * Returns a form for the field-level settings. * * Invoked from \Drupal\field_ui\Form\FieldEditForm to allow administrators to diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php index f719aaf..e615c99 100644 --- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php @@ -19,13 +19,6 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePluginManagerInterface { /** - * {@inheritdoc} - */ - protected $defaults = array( - 'instance_settings' => array(), - ); - - /** * Constructs the FieldTypePluginManager object * * @param \Traversable $namespaces @@ -70,8 +63,12 @@ public function getDefaultSettings($type) { * {@inheritdoc} */ public function getDefaultInstanceSettings($type) { - $info = $this->getDefinition($type); - return isset($info['instance_settings']) ? $info['instance_settings'] : array(); + $plugin_definition = $this->getDefinition($type); + if (!empty($plugin_definition['class'])) { + $plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition); + return $plugin_class::instanceSettings(); + } + return array(); } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index 86dfa01..95b04a6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -17,12 +17,6 @@ * id = "decimal", * label = @Translation("Number (decimal)"), * description = @Translation("This field stores a number in the database in a fixed decimal format."), - * instance_settings = { - * "min" = "", - * "max" = "", - * "prefix" = "", - * "suffix" = "" - * }, * default_widget = "number", * default_formatter = "number_decimal" * ) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 524ccd3..51cc1ce 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -35,6 +35,26 @@ class EntityReferenceItem extends FieldItemBase { /** * {@inheritdoc} */ + public static function settings() { + $settings = parent::settings(); + $settings['target_type'] = \Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'user'; + $settings['target_bundle'] = NULL; + return $settings; + } + + /** + * {@inheritdoc} + */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['handler'] = 'default'; + $settings['handler_settings'] = array(); + return $settings; + } + + /** + * {@inheritdoc} + */ public static function propertyDefinitions(FieldDefinitionInterface $field_definition) { $settings = $field_definition->getSettings(); $target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php index 2d9511b..eda49cc 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php @@ -17,12 +17,6 @@ * id = "float", * label = @Translation("Number (float)"), * description = @Translation("This field stores a number in the database in a floating point format."), - * instance_settings = { - * "min" = "", - * "max" = "", - * "prefix" = "", - * "suffix" = "" - * }, * default_widget = "number", * default_formatter = "number_decimal" * ) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php index 31f3bc6..f22e060 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php @@ -17,12 +17,6 @@ * id = "integer", * label = @Translation("Number (integer)"), * description = @Translation("This field stores a number in the database as an integer."), - * instance_settings = { - * "min" = "", - * "max" = "", - * "prefix" = "", - * "suffix" = "" - * }, * default_widget = "number", * default_formatter = "number_integer" * ) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php index c1270c4..6b32396 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php @@ -17,6 +17,18 @@ /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['min'] = ''; + $settings['max'] = ''; + $settings['prefix'] = ''; + $settings['suffix'] = ''; + return $settings; + } + + /** + * {@inheritdoc} + */ public function instanceSettingsForm(array $form, array &$form_state) { $element = array(); $settings = $this->getSettings(); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php index 0a41d3d..170e0bb 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php @@ -18,14 +18,6 @@ * id = "comment", * label = @Translation("Comments"), * description = @Translation("This field manages configuration and presentation of comments on an entity."), - * instance_settings = { - * "default_mode" = COMMENT_MODE_THREADED, - * "per_page" = 50, - * "form_location" = COMMENT_FORM_BELOW, - * "anonymous" = COMMENT_ANONYMOUS_MAYNOT_CONTACT, - * "subject" = 1, - * "preview" = DRUPAL_OPTIONAL, - * }, * default_widget = "comment_default", * default_formatter = "comment_default" * ) @@ -44,6 +36,20 @@ public static function settings() { /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['default_mode'] = COMMENT_MODE_THREADED; + $settings['per_page'] = 50; + $settings['form_location'] = COMMENT_FORM_BELOW; + $settings['anonymous'] = COMMENT_ANONYMOUS_MAYNOT_CONTACT; + $settings['subject'] = 1; + $settings['preview'] = DRUPAL_OPTIONAL; + return $settings; + } + + /** + * {@inheritdoc} + */ public static function propertyDefinitions(FieldDefinitionInterface $field_definition) { $properties['status'] = DataDefinition::create('integer') ->setLabel(t('Comment status value')); diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 4f15acd..5d29011 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -43,9 +43,6 @@ function entity_reference_field_info_alter(&$info) { $info['entity_reference']['configurable'] = TRUE; $info['entity_reference']['class'] = '\Drupal\entity_reference\ConfigurableEntityReferenceItem'; $info['entity_reference']['list_class'] = '\Drupal\entity_reference\Plugin\Field\FieldType\ConfigurableEntityReferenceFieldItemList'; - $info['entity_reference']['settings']['target_type'] = \Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'user'; - $info['entity_reference']['instance_settings']['handler'] = 'default'; - $info['entity_reference']['instance_settings']['handler_settings'] = array(); $info['entity_reference']['default_widget'] = 'entity_reference_autocomplete'; $info['entity_reference']['default_formatter'] = 'entity_reference_label'; $info['entity_reference']['provider'] = 'entity_reference'; diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php index 061817a..92d5342 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php @@ -513,11 +513,12 @@ public function getSettings() { $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->type); $settings = array(); + $instance_settings = array(); if (isset($field_type_info['class'])) { $settings = $field_type_info['class']::settings(); + $instance_settings = $field_type_info['class']::instanceSettings(); } - // @todo Convert instance settings to method. - return $this->settings + $settings + $field_type_info['instance_settings']; + return $this->settings + $settings + $instance_settings; } /** @@ -525,18 +526,14 @@ public function getSettings() { */ public function getSetting($setting_name) { // @todo See getSettings() about potentially statically caching this. - $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->type); - // We assume here that consecutive array_key_exists() is more efficient than // calling getSettings() when all we need is a single setting. if (array_key_exists($setting_name, $this->settings)) { return $this->settings[$setting_name]; } - elseif (array_key_exists($setting_name, $field_type_info['settings'])) { - return $field_type_info['settings'][$setting_name]; - } - elseif (array_key_exists($setting_name, $field_type_info['instance_settings'])) { - return $field_type_info['instance_settings'][$setting_name]; + $settings = $this->getSettings(); + if (array_key_exists($setting_name, $settings)) { + return $settings[$setting_name]; } else { return NULL; diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php index a608ec2..aad9bbc 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php @@ -19,10 +19,6 @@ * id = "test_field", * label = @Translation("Test field"), * description = @Translation("Dummy field type used for tests."), - * instance_settings = { - * "test_instance_setting" = "dummy test string", - * "test_cached_data" = FALSE - * }, * default_widget = "test_field_widget", * default_formatter = "field_test_default" * ) @@ -43,6 +39,16 @@ public static function settings() { /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['test_instance_setting'] = 'dummy test string'; + $settings['test_cached_data'] = FALSE; + return $settings; + } + + /** + * {@inheritdoc} + */ public static function propertyDefinitions(FieldDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('integer') ->setLabel(t('Test integer value')); diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index a3c7140..7d106ae 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -9,16 +9,6 @@ use Drupal\field\FieldConfigInterface; /** - * Implements hook_field_info_alter(). - * - * Cannot annotate in FieldItem plugin the settings.uri_scheme meta data key - * with a dynamic value. We need to alter the value here. - */ -function file_field_info_alter(&$info) { - $info['file']['settings']['uri_scheme'] = file_default_scheme(); -} - -/** * Returns HTML for an individual file upload widget. * * @param $variables diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php index 77379de..4f15c74 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php @@ -18,12 +18,6 @@ * id = "file", * label = @Translation("File"), * description = @Translation("This field stores the ID of a file as an integer value."), - * instance_settings = { - * "file_extensions" = "txt", - * "file_directory" = "", - * "max_filesize" = "", - * "description_field" = "0" - * }, * default_widget = "file_generic", * default_formatter = "file_default", * list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList" @@ -39,7 +33,19 @@ public static function settings() { $settings['target_type'] = 'file'; $settings['display_field'] = 0; $settings['display_default'] = 0; - $settings['uri_scheme'] = ''; + $settings['uri_scheme'] = file_default_scheme(); + return $settings; + } + + /** + * {@inheritdoc} + */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['file_extensions'] = 'txt'; + $settings['file_directory'] = ''; + $settings['max_filesize'] = ''; + $settings['description_field'] = 0; return $settings; } diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 4407563..5462520 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -8,13 +8,6 @@ use Drupal\Component\Utility\NestedArray; /** - * Implements hook_field_info_alter(). - */ -function image_field_info_alter(&$info) { - $info['image']['settings']['uri_scheme'] = file_default_scheme(); -} - -/** * Returns HTML for an image field widget. * * @param array $variables diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php index 6162a41..62ce6ad 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php @@ -18,24 +18,6 @@ * id = "image", * label = @Translation("Image"), * description = @Translation("This field stores the ID of an image file as an integer value."), - * instance_settings = { - * "file_extensions" = "png gif jpg jpeg", - * "file_directory" = "", - * "max_filesize" = "", - * "alt_field" = "0", - * "alt_field_required" = "0", - * "title_field" = "0", - * "title_field_required" = "0", - * "max_resolution" = "", - * "min_resolution" = "", - * "default_image" = { - * "fid" = NULL, - * "alt" = "", - * "title" = "", - * "width" = NULL, - * "height" = NULL - * } - * }, * default_widget = "image_image", * default_formatter = "image", * list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList" @@ -48,8 +30,6 @@ class ImageItem extends FileItem { */ public static function settings() { $settings = parent::settings(); - $settings['target_type'] = 'file'; - $settings['uri_scheme'] = ''; $settings['default_image'] = array( 'fid' => NULL, 'alt' => '', @@ -77,6 +57,28 @@ public static function settings() { /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + unset($settings['description_field']); + $settings['file_extensions'] = 'png gif jpg jpeg'; + $settings['alt_field'] = 0; + $settings['alt_field_required'] = 0; + $settings['title_field'] = 0; + $settings['title_field_required'] = 0; + $settings['max_resolution'] = ''; + $settings['min_resolution'] = ''; + $settings['default_image'] = array( + 'fid' => NULL, + 'alt' => '', + 'width' => NULL, + 'height' => NULL, + ); + return $settings; + } + + /** + * {@inheritdoc} + */ public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php index e9aff29..726446e 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php @@ -19,9 +19,6 @@ * id = "link", * label = @Translation("Link"), * description = @Translation("Stores a URL string, optional varchar link text, and optional blob of attributes to assemble a link."), - * instance_settings = { - * "title" = "1" - * }, * default_widget = "link_default", * default_formatter = "link" * ) @@ -31,6 +28,15 @@ class LinkItem extends FieldItemBase { /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['title'] = 1; + return $settings; + } + + /** + * {@inheritdoc} + */ public static function propertyDefinitions(FieldDefinitionInterface $field_definition) { $properties['url'] = DataDefinition::create('uri') ->setLabel(t('URL')); diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php index b283d7f..a884a53 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php @@ -19,11 +19,7 @@ * label = @Translation("Boolean"), * description = @Translation("This field stores simple on/off or yes/no options."), * default_widget = "options_buttons", - * default_formatter = "list_default", - * settings = { - * "allowed_values" = { }, - * "allowed_values_function" = "" - * } + * default_formatter = "list_default" * ) */ class ListBooleanItem extends ListItemBase { diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListFloatItem.php index cfd9251..66d59a6 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListFloatItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListFloatItem.php @@ -19,11 +19,7 @@ * label = @Translation("List (float)"), * description = @Translation("This field stores float values from a list of allowed 'value => label' pairs, i.e. 'Fraction': 0 => 0, .25 => 1/4, .75 => 3/4, 1 => 1."), * default_widget = "options_select", - * default_formatter = "list_default", - * settings = { - * "allowed_values" = { }, - * "allowed_values_function" = "" - * } + * default_formatter = "list_default" * ) */ class ListFloatItem extends ListItemBase { diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListIntegerItem.php index ea28a94..5b963c6 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListIntegerItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListIntegerItem.php @@ -19,11 +19,7 @@ * label = @Translation("List (integer)"), * description = @Translation("This field stores integer values from a list of allowed 'value => label' pairs, i.e. 'Lifetime in days': 1 => 1 day, 7 => 1 week, 31 => 1 month."), * default_widget = "options_select", - * default_formatter = "list_default", - * settings = { - * "allowed_values" = { }, - * "allowed_values_function" = "" - * } + * default_formatter = "list_default" * ) */ class ListIntegerItem extends ListItemBase { diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php index de95075..f6e544b 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php @@ -20,6 +20,16 @@ /** * {@inheritdoc} */ + public static function settings() { + $settings = parent::settings(); + $settings['allowed_values'] = array(); + $settings['allowed_values_function'] = ''; + return $settings; + } + + /** + * {@inheritdoc} + */ public function getPossibleValues(AccountInterface $account = NULL) { // Flatten options firstly, because Possible Options may contain group // arrays. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php index bacc4ef..aa8a1f9 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php @@ -19,7 +19,6 @@ * id = "taxonomy_term_reference", * label = @Translation("Term Reference"), * description = @Translation("This field stores a reference to a taxonomy term."), - * instance_settings = { }, * default_widget = "options_select", * default_formatter = "taxonomy_term_reference_link", * list_class = "\Drupal\taxonomy\Plugin\Field\FieldType\TaxonomyTermReferenceFieldItemList" diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php index 0eee199..67d0f3a 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php @@ -16,9 +16,6 @@ * id = "text", * label = @Translation("Text"), * description = @Translation("This field stores varchar text in the database."), - * instance_settings = { - * "text_processing" = "0" - * }, * default_widget = "text_textfield", * default_formatter = "text_default" * ) diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php index 0c85997..b7a1d7a 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php @@ -20,6 +20,15 @@ /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['text_processing'] = 0; + return $settings; + } + + /** + * {@inheritdoc} + */ public static function propertyDefinitions(FieldDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') ->setLabel(t('Text value')); diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php index 934d11f..1cf0385 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php @@ -16,9 +16,6 @@ * id = "text_long", * label = @Translation("Long text"), * description = @Translation("This field stores long text in the database."), - * instance_settings = { - * "text_processing" = "0" - * }, * default_widget = "text_textarea", * default_formatter = "text_default" * ) diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php index 5fe30fc..a645b53 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php @@ -17,10 +17,6 @@ * id = "text_with_summary", * label = @Translation("Long text and summary"), * description = @Translation("This field stores long text in the database along with optional summary text."), - * instance_settings = { - * "text_processing" = "1", - * "display_summary" = "0" - * }, * default_widget = "text_textarea_with_summary", * default_formatter = "text_default" * ) @@ -30,6 +26,16 @@ class TextWithSummaryItem extends TextItemBase { /** * {@inheritdoc} */ + public static function instanceSettings() { + $settings = parent::instanceSettings(); + $settings['text_processing'] = 1; + $settings['display_summary'] = 0; + return $settings; + } + + /** + * {@inheritdoc} + */ public static function propertyDefinitions(FieldDefinitionInterface $field_definition) { $properties = parent::propertyDefinitions($field_definition);