You are here

public static function UiPatternsSettings::getPatternConfiguration in UI Patterns Settings 8.2

Get pattern configuration for a pattern definition.

Parameters

\Drupal\ui_patterns\Definition\PatternDefinition $definition: The definition.

string $variant: The pattern variant.

string $name: The configuration key.

Return value

mixed Setting pattern configuration.

1 call to UiPatternsSettings::getPatternConfiguration()
UIPatternsSettingsExtension::patternConfiguration in src/TwigExtension/UIPatternsSettingsExtension.php
Returns pattern configuration.

File

src/UiPatternsSettings.php, line 208

Class

UiPatternsSettings
UI Patterns setting factory class.

Namespace

Drupal\ui_patterns_settings

Code

public static function getPatternConfiguration(PatternDefinition $definition, $variant = NULL, $name = NULL) {
  $additional = $definition
    ->getAdditional();
  $configuration = isset($additional['configuration']) ? $additional['configuration'] : [];
  if (!empty($variant)) {
    $variant_ob = $definition
      ->getVariant($variant);
    if ($variant_ob != NULL) {
      $variant_ary = $variant_ob
        ->toArray();
      if (isset($variant_ary['configuration'])) {
        $configuration = array_merge($configuration, $variant_ary['configuration']);
      }
    }
  }
  if ($name !== NULL && isset($configuration[$name])) {
    return $configuration[$name];
  }
  return $configuration;
}