diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php index 5970a2b245..3ffbc4ff87 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php @@ -2,10 +2,10 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; +use Drupal\Component\Gettext\PoItem; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\StringTranslation\PluralTranslatableMarkup; /** * Parent plugin for decimal and integer formatters. @@ -88,7 +88,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { $plural_string = $settings['format_plural_string']; } } - $plural_array = explode(PluralTranslatableMarkup::DELIMITER, $plural_string); + $plural_array = explode(PoItem::DELIMITER, $plural_string); for ($i = 0; $i < $plurals; $i) { $elements['format_plural_values'][$i] = [ '#type' => 'textfield', @@ -124,7 +124,7 @@ public static function formatPluralValuesAfterBuild($element, FormStateInterface $keys = $element['#parents']; $array_value = $form_state->getValue($keys); $form_state->unsetValue($keys); - $string_value = implode(PluralTranslatableMarkup::DELIMITER, $array_value); + $string_value = implode(PoItem::DELIMITER, $array_value); array_pop($keys); $keys[] = 'format_plural_string'; $form_state->setValue($keys, $string_value); 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 5a133cb65d..18329ac55d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php @@ -2,9 +2,9 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Component\Gettext\PoItem; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\StringTranslation\PluralTranslatableMarkup; /** * Base class for numeric configurable field types. @@ -49,7 +49,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $langcode = $this->getFieldDefinition()->get('langcode'); $plurals = $this->getNumberOfPlurals($langcode); $labels = $this->getPluralLabels($langcode); - $plural_array = explode(PluralTranslatableMarkup::DELIMITER, $settings['format_plural_string']); + $plural_array = explode(PoItem::DELIMITER, $settings['format_plural_string']); for ($i = 0; $i < $plurals; $i++) { $element['format_plural_values'][$i] = [ '#type' => 'textfield', @@ -85,7 +85,7 @@ public static function formatPluralValuesAfterBuild($element, FormStateInterface $keys = $element['#parents']; $array_value = $form_state->getValue($keys); $form_state->unsetValue($keys); - $string_value = implode(PluralTranslatableMarkup::DELIMITER, $array_value); + $string_value = implode(PoItem::DELIMITER, $array_value); array_pop($keys); $keys[] = 'format_plural_string'; $form_state->setValue($keys, $string_value); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php index 522b93c231..a2be298f91 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php @@ -2,11 +2,11 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; +use Drupal\Component\Gettext\PoItem; use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -105,12 +105,12 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen } // Add prefix and suffix. - if ($field_settings['format_plural_string'] && $this->getSetting('format_plural')) { + if (!empty($field_settings['format_plural_string']) && $this->getSetting('format_plural')) { // The field setting is a string containing all plural variants, suitable // for use in plural formatting, translated into the UI language. Pop // off the last plural variant, and use the parts before/after @count in // that string as the prefix/suffix for this field. - $values = explode(PluralTranslatableMarkup::DELIMITER, $field_settings['format_plural_string']); + $values = explode(PoItem::DELIMITER, $field_settings['format_plural_string']); $labels = explode('@count', array_pop($values)); if (isset($labels[0])) { $element['#field_prefix'] = FieldFilteredMarkup::create(trim($labels[0])); diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php index d4b0c6b62a..ec4ec3720d 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php @@ -2,7 +2,7 @@ namespace Drupal\field\Plugin\migrate\process\d6; -use Drupal\Core\StringTranslation\PluralTranslatableMarkup; +use Drupal\Component\Gettext\PoItem; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; @@ -22,7 +22,7 @@ class FieldInstanceSettings extends ProcessPluginBase { * Set the field instance defaults. */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - list($widget_type, $widget_settings, $field_settings) = $value; + [$widget_type, $widget_settings, $field_settings] = $value; $settings = []; switch ($widget_type) { case 'number': @@ -43,7 +43,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $suffix = isset($suffixes[$i]) ? $suffixes[$i] : $suffixes[count($suffixes) - 1]; $strings[] = $prefix . '@count' . $suffix; } - $settings['format_plural_string'] = implode(PluralTranslatableMarkup::DELIMITER, $strings); + $settings['format_plural_string'] = implode(PoItem::DELIMITER, $strings); } else { $settings['format_plural_string'] = ''; diff --git a/core/modules/field/src/Tests/Update/NumberFieldUpdateTest.php b/core/modules/field/src/Tests/Update/NumberFieldUpdateTest.php index 9cd0fbe89c..85a5a3200f 100644 --- a/core/modules/field/src/Tests/Update/NumberFieldUpdateTest.php +++ b/core/modules/field/src/Tests/Update/NumberFieldUpdateTest.php @@ -2,7 +2,7 @@ namespace Drupal\field\Tests\Update; -use Drupal\Core\StringTranslation\PluralTranslatableMarkup; +use Drupal\Component\Gettext\PoItem; use Drupal\system\Tests\Update\UpdatePathTestBase; /** @@ -45,7 +45,7 @@ public function testUpdateHookN() { $settings = $config['settings']; $this->assertFalse(isset($settings['prefix']), 'Prefix setting has been removed from field settings'); $this->assertFalse(isset($settings['suffix']), 'Suffix setting has been removed from field settings'); - $this->assertEqual($settings['format_plural_string'], 'Sprefix@countSsuffix' . PluralTranslatableMarkup::DELIMITER . 'Pprefix@countPsuffix'); + $this->assertEqual($settings['format_plural_string'], 'Sprefix@countSsuffix' . PoItem::DELIMITER . 'Pprefix@countPsuffix'); // Form mode configuration - there should be a format_plural setting, // and since this was not optional prior to this update, it should be diff --git a/core/modules/system/system.install b/core/modules/system/system.install index b5a0e77779..08d12451e4 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -6,6 +6,7 @@ */ use Drupal\Component\FileSystem\FileSystem as FileSystemComponent; +use Drupal\Component\Gettext\PoItem; use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Environment; @@ -1405,7 +1406,7 @@ function system_update_last_removed() { /** * Update the stored schema data for entity identifier fields. */ -function system_update_8901() { +function system_update_9201() { $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); $entity_type_manager = \Drupal::entityTypeManager(); $installed_storage_schema = \Drupal::keyValue('entity.storage_schema.sql'); @@ -1461,7 +1462,7 @@ function system_update_8901() { /** * Update numeric field prefix/suffix configuration. */ -function system_update_8902($sandbox) { +function system_update_9202($sandbox) { // Update prefix/suffix on numeric fields (types: float, decimal, integer) // to new format_plural_string configuration. Also update associated // formatters and widgets. @@ -1488,7 +1489,7 @@ function system_update_8902($sandbox) { $suffix = isset($suffixes[$i]) ? $suffixes[$i] : $suffixes[count($suffixes) - 1]; $strings[] = $prefix . '@count' . $suffix; } - $settings['format_plural_string'] = implode(PluralTranslatableMarkup::DELIMITER, $strings); + $settings['format_plural_string'] = implode(PoItem::DELIMITER, $strings); } else { $settings['format_plural_string'] = '';