You are here

protected function PatternFormatter::getCurrentVariant in UI Patterns Field Formatters 8

Checks if a given pattern has a corresponding value on the variants array.

Parameters

string $pattern: Pattern ID.

Return value

string|null Variant ID.

3 calls to PatternFormatter::getCurrentVariant()
PatternFormatter::settingsForm in src/Plugin/Field/FieldFormatter/PatternFormatter.php
Returns a form to configure settings for the formatter.
PatternFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/PatternFormatter.php
Returns a short summary for the current formatter settings.
PatternFormatter::viewElements in src/Plugin/Field/FieldFormatter/PatternFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/PatternFormatter.php, line 291

Class

PatternFormatter
Plugin implementation of the 'pattern' formatter.

Namespace

Drupal\ui_patterns_field_formatters\Plugin\Field\FieldFormatter

Code

protected function getCurrentVariant($pattern) {
  $variants = $this
    ->getSetting('variants');
  return !empty($variants) && isset($variants[$pattern]) ? $variants[$pattern] : NULL;
}