File tree Expand file tree Collapse file tree 3 files changed +21
-18
lines changed
templates/Plugin/Field/_widget
tests/functional/Generator/Plugin/Field/_widget
_n_deps/src/Plugin/Field/FieldWidget
_w_deps/src/Plugin/Field/FieldWidget Expand file tree Collapse file tree 3 files changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ declare(strict_types=1);
66namespace Drupal\ {{ machine_name }}\Plugin\Field\ FieldWidget ;
77
88{% apply sort_namespaces % }
9+ use Drupal\Core\Field\Attribute\FieldWidget ;
910use Drupal\Core\Field\FieldItemListInterface ;
1011use Drupal\Core\Field\WidgetBase ;
1112use Drupal\Core\Form\FormStateInterface ;
13+ use Drupal\Core\StringTranslation\TranslatableMarkup ;
1214 {% if services % }
1315{{ di . use (services ) }}
1416use Drupal\Core\Plugin\ContainerFactoryPluginInterface ;
@@ -18,13 +20,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
1820
1921/**
2022 * Defines the '{{ plugin_id }}' field widget.
21- *
22- * @FieldWidget(
23- * id = "{{ plugin_id }}",
24- * label = @Translation("{{ plugin_label }}"),
25- * field_types = {"string"},
26- * )
2723 */
24+ # [FieldWidget(
25+ id : ' {{ plugin_id }}' ,
26+ label : new TranslatableMarkup (' {{ plugin_label }}' ),
27+ field_types : [' string' ],
28+ )]
2829final class {{ class }} extends WidgetBase {% if services % }implements ContainerFactoryPluginInterface {% endif % }{
2930
3031{% if services % }
Original file line number Diff line number Diff line change 44
55namespace Drupal \foo \Plugin \Field \FieldWidget ;
66
7+ use Drupal \Core \Field \Attribute \FieldWidget ;
78use Drupal \Core \Field \FieldItemListInterface ;
89use Drupal \Core \Field \WidgetBase ;
910use Drupal \Core \Form \FormStateInterface ;
11+ use Drupal \Core \StringTranslation \TranslatableMarkup ;
1012
1113/**
1214 * Defines the 'foo_example' field widget.
13- *
14- * @FieldWidget(
15- * id = "foo_example",
16- * label = @Translation("Example"),
17- * field_types = {"string"},
18- * )
1915 */
16+ #[FieldWidget(
17+ id: 'foo_example ' ,
18+ label: new TranslatableMarkup ('Example ' ),
19+ field_types: ['string ' ],
20+ )]
2021final class ExampleWidget extends WidgetBase {
2122
2223 /**
Original file line number Diff line number Diff line change 66
77use Drupal \Core \CronInterface ;
88use Drupal \Core \Database \Connection ;
9+ use Drupal \Core \Field \Attribute \FieldWidget ;
910use Drupal \Core \Field \FieldItemListInterface ;
1011use Drupal \Core \Field \WidgetBase ;
1112use Drupal \Core \Form \FormStateInterface ;
1213use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
14+ use Drupal \Core \StringTranslation \TranslatableMarkup ;
1315use Symfony \Component \DependencyInjection \ContainerInterface ;
1416
1517/**
1618 * Defines the 'foo_example' field widget.
17- *
18- * @FieldWidget(
19- * id = "foo_example",
20- * label = @Translation("Example"),
21- * field_types = {"string"},
22- * )
2319 */
20+ #[FieldWidget(
21+ id: 'foo_example ' ,
22+ label: new TranslatableMarkup ('Example ' ),
23+ field_types: ['string ' ],
24+ )]
2425final class ExampleWidget extends WidgetBase implements ContainerFactoryPluginInterface {
2526
2627 /**
You can’t perform that action at this time.
0 commit comments