File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drupal\comment\Plugin\Field\FieldType;
4
+
5
+ use Drupal\Core\Field\FieldItemBase;
6
+
7
+ /**
8
+ * @property ?int $status
9
+ * @property ?int $cid
10
+ * @property ?int $last_comment_timestamp
11
+ * @property ?string $last_comment_name
12
+ * @property ?int $last_comment_uid
13
+ * @property ?int $comment_count
14
+ */
15
+ class CommentItem extends FieldItemBase implements CommentItemInterface {
16
+
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drupal\comment\Plugin\Field\FieldType;
4
+
5
+ interface CommentItemInterface {
6
+ }
Original file line number Diff line number Diff line change 2
2
3
3
namespace DrupalEntityFields ;
4
4
5
+ use Drupal \comment \Plugin \Field \FieldType \CommentItem ;
5
6
use Drupal \Core \Field \Plugin \Field \FieldType \BooleanItem ;
6
7
use Drupal \Core \Field \Plugin \Field \FieldType \ChangedItem ;
7
8
use Drupal \Core \Field \Plugin \Field \FieldType \CreatedItem ;
30
31
31
32
$ node = Node::create (['type ' => 'page ' ]);
32
33
34
+ // CommentItem.
35
+ $ comment_field = $ node ->get ('field_comment ' )->first ();
36
+ assert ($ comment_field instanceof CommentItem);
37
+ assertType (CommentItem::class, $ comment_field );
38
+ assertType ('int|null ' , $ comment_field ->status );
39
+ assertType ('int|null ' , $ comment_field ->cid );
40
+ assertType ('int|null ' , $ comment_field ->last_comment_timestamp );
41
+ assertType ('string|null ' , $ comment_field ->last_comment_name );
42
+ assertType ('int|null ' , $ comment_field ->comment_count );
43
+
33
44
// LinkItem.
34
45
$ link_field = $ node ->get ('field_link ' )->first ();
35
46
assert ($ link_field instanceof LinkItem);
You can’t perform that action at this time.
0 commit comments