File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
stubs/Drupal/datetime_range/Plugin/Field/FieldType Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drupal\datetime_range\Plugin\Field\FieldType;
4
+
5
+ use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
6
+
7
+ /**
8
+ * @property-read null $date
9
+ * Even though this extends DateTimeItem, the date property does not actually
10
+ * exist. It is not possible to undo a property definition.
11
+ * @property-read ?\Drupal\Core\Datetime\DrupalDateTime $start_date
12
+ * @property ?string $end_value
13
+ * @property-read ?\Drupal\Core\Datetime\DrupalDateTime $end_date
14
+ */
15
+ class DateRangeItem extends DateTimeItem {
16
+
17
+ }
Original file line number Diff line number Diff line change 19
19
use Drupal \Core \Field \Plugin \Field \FieldType \UriItem ;
20
20
use Drupal \Core \Field \Plugin \Field \FieldType \UuidItem ;
21
21
use Drupal \datetime \Plugin \Field \FieldType \DateTimeItem ;
22
+ use Drupal \datetime_range \Plugin \Field \FieldType \DateRangeItem ;
22
23
use Drupal \file \Plugin \Field \FieldType \FileItem ;
23
24
use Drupal \file \Plugin \Field \FieldType \FileUriItem ;
24
25
use Drupal \link \Plugin \Field \FieldType \LinkItem ;
145
146
assertType ('string|null ' , $ datetime_field ->value );
146
147
assertType ('Drupal\Core\Datetime\DrupalDateTime|null ' , $ datetime_field ->date );
147
148
149
+ // DateRangeItem.
150
+ $ daterange_field = $ node ->get ('field_daterange ' )->first ();
151
+ assert ($ daterange_field instanceof DateRangeItem);
152
+ assertType (DateRangeItem::class, $ daterange_field );
153
+ assertType ('string|null ' , $ daterange_field ->value );
154
+ assertType ('\Drupal\Core\Datetime\DrupalDateTime|null ' , $ daterange_field ->start_date );
155
+ assertType ('string|null ' , $ daterange_field ->end_value );
156
+ assertType ('\Drupal\Core\Datetime\DrupalDateTime|null ' , $ daterange_field ->end_date );
157
+
148
158
// FileItem.
149
159
$ file_field = $ node ->get ('field_file ' )->first ();
150
160
assert ($ file_field instanceof FileItem);
You can’t perform that action at this time.
0 commit comments