You are here

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

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

Parameters

string $pattern: The pattern.

Return value

string|null The variant.

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

File

src/Plugin/Field/FieldFormatter/PatternWrapperEntityReferenceFormatter.php, line 253

Class

PatternWrapperEntityReferenceFormatter
Plugin implementation of 'pattern_wrapper_entity_reference_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;
}