diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimeDefaultFormatter.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimeDefaultFormatter.php index 2ed1b8a..88a2184 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimeDefaultFormatter.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/formatter/DatetimeDefaultFormatter.php @@ -64,15 +64,15 @@ class DateTimeDefaultFormatter extends FormatterBase implements ContainerFactory * The formatter label display setting. * @param string $view_mode * The view mode. - * @param \Drupal\Core\Datetime\Date $dateService + * @param \Drupal\Core\Datetime\Date $date_service * The date service. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $date_storage * The date storage controller. */ - public function __construct($plugin_id, array $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, Date $dateService, EntityStorageControllerInterface $date_storage) { + public function __construct($plugin_id, array $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, Date $date_service, EntityStorageControllerInterface $date_storage) { parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode); - $this->dateService = $dateService; + $this->dateService = $date_service; $this->dateStorage = $date_storage; } diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php index f3cb4cb..6eb0c9a 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php @@ -58,6 +58,15 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac public function createInstance($plugin_id, array $configuration) { $plugin_definition = $this->discovery->getDefinition($plugin_id); $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); + + // @todo This is copied from \Drupal\Core\Plugin\Factory\ContainerFactory. + // Find a way to restore sanity to + // \Drupal\field\Plugin\Type\Formatter\FormatterBase::__construct(). + // If the plugin provides a factory method, pass the container to it. + if (is_subclass_of($plugin_class, 'Drupal\Core\Plugin\ContainerFactoryPluginInterface')) { + return $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition); + } + return new $plugin_class($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['label'], $configuration['view_mode']); } diff --git a/core/modules/system/config/system.date_format.fallback.yml b/core/modules/system/config/system.date_format.fallback.yml index e8cab2f..a9e3eb1 100644 --- a/core/modules/system/config/system.date_format.fallback.yml +++ b/core/modules/system/config/system.date_format.fallback.yml @@ -1,6 +1,6 @@ id: fallback uuid: cf0ad071-ded7-4750-b008-8c74f200ff8d -label: 'Fallback date' +label: 'Fallback date format' status: '1' langcode: en locked: '1' diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index bb90061..6c0d23a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -83,7 +83,7 @@ function testAdminDefinedFormatDate() { $timestamp = strtotime('2007-03-10T00:00:00+00:00'); $this->assertIdentical(format_date($timestamp, 'example_style', '', 'America/Los_Angeles'), '9 Mar 07', 'Test format_date() using an admin-defined date type.'); $this->assertIdentical(format_date($timestamp, 'example_style_uppercase', '', 'America/Los_Angeles'), '9 Mar 2007', 'Test format_date() using an admin-defined date type with different case.'); - $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'medium'), 'Test format_date() defaulting to medium when $type not found.'); + $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'fallback'), 'Test format_date() defaulting to `fallback` when $type not found.'); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index cef0922..f4fe3ce 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1916,6 +1916,7 @@ function system_update_8045() { // Install the new HTML date formats. $new_formats = array( + 'system.date_format.fallback', 'system.date_format.html_date', 'system.date_format.html_datetime', 'system.date_format.html_month',