You are here

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

Exposed pattern setting definitions.

Returns a list of all exposed pattern setting definitions filtered by the provided field storage type.

Parameters

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

string $field_storage_type: The field storage type.

Return value

array The configuration array. Key: pattern::setting. Keys: 'label' = 'The setting label' 'definition' = The pattern definition

1 call to UiPatternsSettings::getExposedPatternDefinition()
ui_patterns_settings_form_field_storage_config_edit_form_alter in ./ui_patterns_settings.module
Implements hook_form_field_storage_config_edit_form_alter().

File

src/UiPatternsSettings.php, line 167

Class

UiPatternsSettings
UI Patterns setting factory class.

Namespace

Drupal\ui_patterns_settings

Code

public static function getExposedPatternDefinition(PatternDefinition $definition, $field_storage_type) {
  $additional = $definition
    ->getAdditional();
  $exposed = [];
  if (isset($additional['allow_variant_expose']) && $additional['allow_variant_expose'] === TRUE && $field_storage_type === 'list_string') {
    $exposed[$definition
      ->id() . '::variant'] = [
      'label' => $definition
        ->getLabel() . ' Variants',
      'definition' => $definition,
    ];
  }
  $settings = self::getPatternDefinitionSettings($definition);

  /** @var \Drupal\ui_patterns\Definition\PatternDefinitionSetting $setting */
  foreach ($settings as $setting) {
    if ($setting
      ->allowExpose()) {
      $setting_type = self::createSettingType($definition, $setting);
      if (in_array($field_storage_type, $setting_type
        ->fieldStorageExposableTypes())) {
        $exposed[$definition
          ->id() . '::' . $setting
          ->getName()] = [
          'label' => $definition
            ->getLabel() . ' ' . $setting
            ->getLabel(),
          'definition' => $definition,
        ];
      }
    }
  }
  return $exposed;
}