You are here

private static function UiPatternsSettings::preprocessExposedFields in UI Patterns Settings 8.2

Preprocess exposed settings variables.

Parameters

\Drupal\Core\Entity\ContentEntityBase $entity: The entity.

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

Return value

array The processed variables.

1 call to UiPatternsSettings::preprocessExposedFields()
UiPatternsSettings::preprocess in src/UiPatternsSettings.php
Preprocess all settings variables.

File

src/UiPatternsSettings.php, line 57

Class

UiPatternsSettings
UI Patterns setting factory class.

Namespace

Drupal\ui_patterns_settings

Code

private static function preprocessExposedFields(ContentEntityBase $entity, PatternDefinition $definition) {
  $processed_settings = [];
  $mapping = self::getConfigManager()
    ->getMappingByType($entity
    ->getEntityTypeId());
  foreach ($mapping as $field => $pattern_setting) {
    if ($entity
      ->hasField($field)) {
      [
        $pattern_id,
        $setting_id,
      ] = explode('::', $pattern_setting);
      if ($setting_id !== 'variant') {
        $pattern_definition = UiPatterns::getPatternDefinition($pattern_id);
        $setting_definition = UiPatternsSettings::getPatternDefinitionSetting($pattern_definition, $setting_id);
        $settingType = UiPatternsSettings::createSettingType($definition, $setting_definition);
        $processed_settings[$setting_id] = $settingType
          ->preprocessExposedField($entity
          ->get($field));
      }
    }
  }
  return $processed_settings;
}