diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateRangeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateRangeItem.php index dfe036f..49d6f49 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateRangeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateRangeItem.php @@ -7,6 +7,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Field\FieldItemBase; +use Drupal\datetime\DateTimeComputed; /** * Plugin implementation of the 'daterange' field type. @@ -58,7 +59,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel ->setLabel(t('Computed start date')) ->setDescription(t('The computed start DateTime object.')) ->setComputed(TRUE) - ->setClass('\Drupal\datetime\DateTimeComputed') + ->setClass(DateTimeComputed::class) ->setSetting('date source', 'value'); $properties['value2'] = DataDefinition::create('datetime_iso8601') @@ -69,7 +70,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel ->setLabel(t('Computed end date')) ->setDescription(t('The computed end DateTime object.')) ->setComputed(TRUE) - ->setClass('\Drupal\datetime\DateTimeComputed') + ->setClass(DateTimeComputed::class) ->setSetting('date source', 'value2'); return $properties; @@ -169,12 +170,4 @@ public function onChange($property_name, $notify = TRUE) { parent::onChange($property_name, $notify); } - /** - * {@inheritdoc} - */ - public static function mainPropertyName() { - // A date range item is a compound value, so there is no main property name. - return NULL; - } - } diff --git a/core/modules/datetime/src/Tests/DateRangeFieldTest.php b/core/modules/datetime/src/Tests/DateRangeFieldTest.php index 512840a..c005668 100644 --- a/core/modules/datetime/src/Tests/DateRangeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateRangeFieldTest.php @@ -132,7 +132,7 @@ protected function setUp() { /** * Tests date field functionality. */ - function testDateRangeField() { + public function testDateRangeField() { $field_name = $this->fieldStorage->getName(); // Loop through defined timezones to test that date-only fields work at the @@ -253,7 +253,7 @@ function testDateRangeField() { /** * Tests date and time field. */ - function testDatetimeRangeField() { + public function testDatetimeRangeField() { $field_name = $this->fieldStorage->getName(); // Ensure the field to a datetime field. @@ -349,7 +349,7 @@ function testDatetimeRangeField() { /** * Tests all-day field. */ - function testAlldayRangeField() { + public function testAlldayRangeField() { $field_name = $this->fieldStorage->getName(); // Ensure field is set to a all-day field. @@ -440,7 +440,7 @@ function testAlldayRangeField() { /** * Tests Date Range List Widget functionality. */ - function testDatelistWidget() { + public function testDatelistWidget() { $field_name = $this->fieldStorage->getName(); // Ensure field is set to a date only field. @@ -770,7 +770,7 @@ protected function datelistDataProvider() { /** * Test default value functionality. */ - function testDefaultValue() { + public function testDefaultValue() { // Create a test content type. $this->drupalCreateContentType(['type' => 'date_content']); @@ -905,7 +905,7 @@ function testDefaultValue() { /** * Test that invalid values are caught and marked as invalid. */ - function testInvalidField() { + public function testInvalidField() { // Change the field to a datetime field. $this->fieldStorage->setSetting('daterange_type', DateRangeItem::DATERANGE_TYPE_DATETIME); $this->fieldStorage->save();