You are here

private function LibraryDeriver::removeWingsuitExtensions in Gin Layout Builder 8.2

Removes Wingsuit YAML extensions.

1 call to LibraryDeriver::removeWingsuitExtensions()
LibraryDeriver::getPatterns in modules/wingsuit_ui_patterns/src/Plugin/Deriver/LibraryDeriver.php
Get pattern definition objects.

File

modules/wingsuit_ui_patterns/src/Plugin/Deriver/LibraryDeriver.php, line 136

Class

LibraryDeriver
Class LibraryDeriver.

Namespace

Drupal\wingsuit_ui_patterns\Plugin\Deriver

Code

private function removeWingsuitExtensions(&$definition) {
  if (isset($definition['fields'])) {
    $fields =& $definition['fields'];
    foreach ($fields as &$field) {
      if (isset($field['preview']['faker'])) {
        unset($field['preview']['faker']);
        $field['preview'] = 'Faked text';
        continue;
      }

      // Remove preview lists.
      if (isset($field['preview'][0]['id'])) {
        $field['preview'] = $field['preview'][0];
      }
      if (isset($field['preview']['id'])) {
        $field['preview']['theme'] = $field['preview']['id'];
      }
      foreach ([
        'id',
        'settings',
        'fields',
        'variant',
      ] as $key) {
        if (isset($field['preview'][$key])) {
          unset($field['preview'][$key]);
        }
      }
    }
  }
}