You are here

protected function HeadingWidget::getTypes in Heading field 8

Get the available heading types.

Return value

array The heading size labels keyed by their size (h1-h6).

2 calls to HeadingWidget::getTypes()
HeadingWidget::formElement in src/Plugin/Field/FieldWidget/HeadingWidget.php
Returns the form for a single field widget.
HeadingWidget::formElementSize in src/Plugin/Field/FieldWidget/HeadingWidget.php
Create the size form element.

File

src/Plugin/Field/FieldWidget/HeadingWidget.php, line 108

Class

HeadingWidget
Heading widget for the heading field type.

Namespace

Drupal\heading\Plugin\Field\FieldWidget

Code

protected function getTypes() {
  $allowed_sizes = array_filter($this->fieldDefinition
    ->getSetting('allowed_sizes'));
  $sizes = [
    'h1' => $this
      ->t('Heading 1'),
    'h2' => $this
      ->t('Heading 2'),
    'h3' => $this
      ->t('Heading 3'),
    'h4' => $this
      ->t('Heading 4'),
    'h5' => $this
      ->t('Heading 5'),
    'h6' => $this
      ->t('Heading 6'),
  ];
  return array_intersect_key($sizes, $allowed_sizes);
}