Same name and namespace in other branches
  1. 8.x-2.x src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php \Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterSwatch::getShape() 1 comment

This is used to get the shape.

Parameters

string|null $shape: The specific shape name to get.

Return value

\Drupal\Component\Render\MarkupInterface[]|\Drupal\Component\Render\MarkupInterface An array of shape ids/names or translated name of the specified shape.

2 calls to ColorFieldFormatterSwatch::getShape()
ColorFieldFormatterSwatch::settingsForm in src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php
ColorFieldFormatterSwatch::settingsSummary in src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php

File

src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php, line 164

Class

ColorFieldFormatterSwatch
Plugin implementation of the color_field swatch formatter.

Namespace

Drupal\color_field\Plugin\Field\FieldFormatter

Code

protected function getShape(?string $shape = NULL) : array|MarkupInterface {
    $formats = [];
    $formats['square'] = $this->t('Square');
    $formats['circle'] = $this->t('Circle');
    $formats['parallelogram'] = $this->t('Parallelogram');
    $formats['triangle'] = $this->t('Triangle');
    if ($shape) {
        return $formats[$shape];
    }
    return $formats;
}