File tree Expand file tree Collapse file tree 3 files changed +25
-20
lines changed
templates/Plugin/Field/_formatter
tests/functional/Generator/Plugin/Field/_formatter
_n_config/src/Plugin/Field/FieldFormatter
_w_config/src/Plugin/Field/FieldFormatter Expand file tree Collapse file tree 3 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,24 @@ declare(strict_types=1);
44
55namespace Drupal\ {{ machine_name }}\Plugin\Field\ FieldFormatter ;
66
7+ {% apply sort_namespaces % }
8+ use Drupal\Core\Field\Attribute\FieldFormatter ;
79use Drupal\Core\Field\FieldItemListInterface ;
810use Drupal\Core\Field\FormatterBase ;
9- {% if configurable % }
11+ use Drupal\Core\StringTranslation\TranslatableMarkup ;
12+ {% if configurable % }
1013use Drupal\Core\Form\FormStateInterface ;
11- {% endif % }
14+ {% endif % }
15+ {% endapply % }
1216
1317/**
1418 * Plugin implementation of the '{{ plugin_label }}' formatter.
15- *
16- * @FieldFormatter(
17- * id = "{{ plugin_id }}",
18- * label = @Translation("{{ plugin_label }}"),
19- * field_types = {"string"},
20- * )
2119 */
20+ # [FieldFormatter(
21+ id : ' {{ plugin_id }}' ,
22+ label : new TranslatableMarkup (' {{ plugin_label }}' ),
23+ field_types : [' string' ],
24+ )]
2225final class {{ class }} extends FormatterBase {
2326
2427{% if configurable % }
Original file line number Diff line number Diff line change 44
55namespace Drupal \foo \Plugin \Field \FieldFormatter ;
66
7+ use Drupal \Core \Field \Attribute \FieldFormatter ;
78use Drupal \Core \Field \FieldItemListInterface ;
89use Drupal \Core \Field \FormatterBase ;
10+ use Drupal \Core \StringTranslation \TranslatableMarkup ;
911
1012/**
1113 * Plugin implementation of the 'Zoo' formatter.
12- *
13- * @FieldFormatter(
14- * id = "foo_zoo",
15- * label = @Translation("Zoo"),
16- * field_types = {"string"},
17- * )
1814 */
15+ #[FieldFormatter(
16+ id: 'foo_zoo ' ,
17+ label: new TranslatableMarkup ('Zoo ' ),
18+ field_types: ['string ' ],
19+ )]
1920final class ZooFormatter extends FormatterBase {
2021
2122 /**
Original file line number Diff line number Diff line change 44
55namespace Drupal \foo \Plugin \Field \FieldFormatter ;
66
7+ use Drupal \Core \Field \Attribute \FieldFormatter ;
78use Drupal \Core \Field \FieldItemListInterface ;
89use Drupal \Core \Field \FormatterBase ;
910use Drupal \Core \Form \FormStateInterface ;
11+ use Drupal \Core \StringTranslation \TranslatableMarkup ;
1012
1113/**
1214 * Plugin implementation of the 'Zoo' formatter.
13- *
14- * @FieldFormatter(
15- * id = "foo_zoo",
16- * label = @Translation("Zoo"),
17- * field_types = {"string"},
18- * )
1915 */
16+ #[FieldFormatter(
17+ id: 'foo_zoo ' ,
18+ label: new TranslatableMarkup ('Zoo ' ),
19+ field_types: ['string ' ],
20+ )]
2021final class ZooFormatter extends FormatterBase {
2122
2223 /**
You can’t perform that action at this time.
0 commit comments