File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
stubs/Drupal/file/Plugin/Field/FieldType Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ parameters:
44
44
- stubs/Drupal/Core/TypedData/TypedData.stub
45
45
- stubs/Drupal/Core/TypedData/TypedDataInterface.stub
46
46
- stubs/Drupal/Core/TypedData/Plugin/DataType/Map.stub
47
+ - stubs/Drupal/file/Plugin/Field/FieldType/FileItem.stub
48
+ - stubs/Drupal/file/Plugin/Field/FieldType/FileUriItem.stub
47
49
- stubs/Drupal/link/LinkItemInterface.stub
48
50
- stubs/Drupal/link/Plugin/Field/FieldType/LinkItem.stub
49
51
drupal :
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drupal\file\Plugin\Field\FieldType;
4
+
5
+ use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
6
+
7
+ /**
8
+ * @property bool $display
9
+ * @property string $description
10
+ */
11
+ class FileItem extends EntityReferenceItem {
12
+
13
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drupal\file\Plugin\Field\FieldType;
4
+
5
+ use Drupal\Core\Field\Plugin\Field\FieldType\UriItem;
6
+
7
+ /**
8
+ * @property string $url
9
+ */
10
+ class FileUriItem extends UriItem {
11
+
12
+ }
Original file line number Diff line number Diff line change 18
18
use Drupal \Core \Field \Plugin \Field \FieldType \TimestampItem ;
19
19
use Drupal \Core \Field \Plugin \Field \FieldType \UriItem ;
20
20
use Drupal \Core \Field \Plugin \Field \FieldType \UuidItem ;
21
+ use Drupal \file \Plugin \Field \FieldType \FileItem ;
22
+ use Drupal \file \Plugin \Field \FieldType \FileUriItem ;
21
23
use Drupal \link \Plugin \Field \FieldType \LinkItem ;
22
24
use Drupal \node \Entity \Node ;
23
25
use function PHPStan \Testing \assertType ;
131
133
assert ($ uuid_field instanceof UuidItem);
132
134
assertType (UuidItem::class, $ uuid_field );
133
135
assertType ('string ' , $ uuid_field ->value );
136
+
137
+ // FileItem.
138
+ $ file_field = $ node ->get ('field_file ' )->first ();
139
+ assert ($ file_field instanceof FileItem);
140
+ assertType (FileItem::class, $ file_field );
141
+ assertType ('bool ' , $ file_field ->display );
142
+ assertType ('string ' , $ file_field ->description );
143
+
144
+ // FileUriItem.
145
+ $ file_uri_field = $ node ->get ('field_file ' )->first ();
146
+ assert ($ file_uri_field instanceof FileUriItem);
147
+ assertType (FileUriItem::class, $ file_uri_field );
148
+ assertType ('string ' , $ file_uri_field ->url );
You can’t perform that action at this time.
0 commit comments