3 namespace Drupal\{{ machine_name }}\Plugin\Field\FieldFormatter;
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\Core\Field\FormatterBase;
8 use Drupal\Core\Form\FormStateInterface;
12 * Plugin implementation of the '{{ plugin_label }}' formatter.
15 * id = "{{ plugin_id }}",
16 * label = @Translation("{{ plugin_label }}"),
22 class {{ class }} extends FormatterBase {
28 public static function defaultSettings() {
31 ] + parent::defaultSettings();
37 public function settingsForm(array $form, FormStateInterface $form_state) {
40 '#type' => 'textfield',
41 '#title' => $this->t('Foo'),
42 '#default_value' => $this->getSetting('foo'),
51 public function settingsSummary() {
52 $summary[] = $this->t('Foo: @foo', ['@foo' => $this->getSetting('foo')]);
60 public function viewElements(FieldItemListInterface $items, $langcode) {
63 foreach ($items as $delta => $item) {
66 '#markup' => $item->value,