diff --git a/README.md b/README.md index ed431c2..5fcad07 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,12 @@ Extends core Datetime and Datetime Range functionality. 1) "Date and time range with duration" is a field widget for the core datetime_range field type that allows content creators to select a start date/time and then optionally define the absolute end time (like the core -widget) or to specify a duration (an offset relative to the start date/time). - -To use this widget, a site must additionally install the duration_field module +widget) or to specify a duration (an offset relative to the start date/time). To +use this widget, a site must additionally install the duration_field module (version 8.x-2.0-rc2 or higher). + +2) "Select list, no time" is a field widget for the core datetime field type +that allows content creators to display datetime fields with only the date. Core +itself only supports displaying dates in a select list with time. This is +sometimes not convenient when the time is irrelevant and the date is what is +needed to be displayed. diff --git a/src/Plugin/Field/FieldWidget/DateConfigurableListWidget.php b/src/Plugin/Field/FieldWidget/DateConfigurableListWidget.php index 9e0d15e..a248beb 100644 --- a/src/Plugin/Field/FieldWidget/DateConfigurableListWidget.php +++ b/src/Plugin/Field/FieldWidget/DateConfigurableListWidget.php @@ -9,24 +9,24 @@ use Drupal\Core\Field\FieldDefinitionInterface; * * @FieldWidget( * id = "datatime_extras_configurable_list", - * label = @Translation("Configurable list"), + * label = @Translation("Configurable list (deprecated)"), * field_types = { * "datetime" * } * ) * - * @deprecated in 1.x and will be removed in 2.x. Use - * \Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeConfigurableList + * @deprecated in 1.x and will be removed before 2.0. Use + * \Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeConfigurableListWidget * instead. */ -class DateConfigurableListWidget extends DateTimeConfigurableList { +class DateConfigurableListWidget extends DateTimeDatelistNoTimeWidget { /** * {@inheritdoc} */ 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); - @trigger_error('The ' . __NAMESPACE__ . '\DateConfigurableListWidget is deprecated in 1.x and will be removed before 2.0. Instead, use ' . __NAMESPACE__ . '\DateTimeConfigurableList.', E_USER_DEPRECATED); + @trigger_error('The ' . __NAMESPACE__ . '\DateConfigurableListWidget is deprecated in 1.x and will be removed before 2.0. Instead, use ' . __NAMESPACE__ . '\DateTimeDatelistNoTimeWidget.', E_USER_DEPRECATED); } } diff --git a/src/Plugin/Field/FieldWidget/DateTimeDatelistNoTimeWidget.php b/src/Plugin/Field/FieldWidget/DateTimeDatelistNoTimeWidget.php index cbfb16a..71263dc 100644 --- a/src/Plugin/Field/FieldWidget/DateTimeDatelistNoTimeWidget.php +++ b/src/Plugin/Field/FieldWidget/DateTimeDatelistNoTimeWidget.php @@ -7,7 +7,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget; /** - * Plugin implementation of the 'datatime_extras_configurable_list' widget. + * Plugin implementation of the 'datetime_datelist_no_time' widget. * * @FieldWidget( * id = "datetime_datelist_no_time", @@ -17,7 +17,7 @@ use Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget; * }, * ) */ -class DateTimeConfigurableListWidget extends DateTimeDatelistWidget { +class DateTimeDatelistNoTimeWidget extends DateTimeDatelistWidget { /** * {@inheritdoc} diff --git a/tests/src/Kernel/DateConfigurableListWidgetTest.php b/tests/src/Kernel/DateConfigurableListWidgetTest.php index 1557b62..2615bab 100644 --- a/tests/src/Kernel/DateConfigurableListWidgetTest.php +++ b/tests/src/Kernel/DateConfigurableListWidgetTest.php @@ -39,7 +39,7 @@ class DateConfigurableListWidgetTest extends KernelTestBase { ], ]; - $this->expectDeprecation('The Drupal\datetime_extras\Plugin\Field\FieldWidget\DateConfigurableListWidget is deprecated in 1.x and will be removed before 2.0. Instead, use Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeConfigurableList.'); + $this->expectDeprecation('The Drupal\datetime_extras\Plugin\Field\FieldWidget\DateConfigurableListWidget is deprecated in 1.x and will be removed before 2.0. Instead, use Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeDatelistNoTimeWidget.'); $this->container->get('plugin.manager.field.widget')->getInstance($widget_options); } diff --git a/tests/src/Kernel/DateTimeDatelistNoTimeWidgetTest.php b/tests/src/Kernel/DateTimeDatelistNoTimeWidgetTest.php index 37aacd4..3031645 100644 --- a/tests/src/Kernel/DateTimeDatelistNoTimeWidgetTest.php +++ b/tests/src/Kernel/DateTimeDatelistNoTimeWidgetTest.php @@ -3,42 +3,25 @@ namespace Drupal\Tests\datetime_extras\Kernel; use Drupal\Core\Field\BaseFieldDefinition; -use Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeConfigurableListWidget; +use Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeDatelistNoTimeWidget; use Drupal\KernelTests\KernelTestBase; /** * Test the DateTimeConfigurableList for datetime fields. * - * @coversDefaultClass \Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeConfigurableListWidget + * @coversDefaultClass \Drupal\datetime_extras\Plugin\Field\FieldWidget\DateTimeDatelistNoTimeWidget * @group datetime_extras */ -class DateTimeConfigurableListTest extends KernelTestBase { +class DateTimeDatelistNoTimeWidgetTest extends KernelTestBase { /** * {@inheritdoc} */ protected static $modules = [ - 'user', - 'system', - 'field', - 'text', 'datetime', 'datetime_extras', ]; - /** - * Set the default field storage backend for fields created during tests. - */ - protected function setUp() { - parent::setUp(); - - $this->installEntitySchema('user'); - $this->installSchema('system', ['sequences', 'key_value']); - - // Set default storage backend and configure the theme system. - $this->installConfig(['field', 'system']); - } - /** * @covers ::__construct */ @@ -50,12 +33,12 @@ class DateTimeConfigurableListTest extends KernelTestBase { 'field_definition' => $base_field_definition, 'form_mode' => 'default', 'configuration' => [ - 'type' => 'datetime_configurable_list', + 'type' => 'datetime_datelist_no_time', ], ]; $instance = $this->container->get('plugin.manager.field.widget')->getInstance($widget_options); - $this->assertInstanceOf(DateTimeConfigurableListWidget::class, $instance); + $this->assertInstanceOf(DateTimeDatelistNoTimeWidget::class, $instance); } }