Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
WidgetLayoutHooks
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 nameWidgetLayouts
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\name\Hook;
6
7use Drupal\Core\Hook\Attribute\Hook;
8use Drupal\Core\StringTranslation\StringTranslationTrait;
9
10/**
11 * Hook implementations that expose Name module's own widget layouts.
12 *
13 * @internal
14 */
15final class WidgetLayoutHooks {
16
17  use StringTranslationTrait;
18
19  /**
20   * Implements hook_name_widget_layouts().
21   */
22  // phpcs:ignore Drupal.Commenting.PostStatementComment.Found -- #[Hook] is a PHP attribute, not a trailing comment.
23  #[Hook('name_widget_layouts')] // @phpstan-ignore attribute.notFound
24  public function nameWidgetLayouts(): array {
25    return [
26      'stacked' => [
27        'label' => $this->t('Stacked'),
28      ],
29      'inline' => [
30        'label'              => $this->t('Inline'),
31        'library'            => [
32          'name/widget.inline',
33        ],
34        'wrapper_attributes' => [
35          'class' => ['form--inline', 'clearfix'],
36        ],
37      ],
38    ];
39  }
40
41}