You are here

function _views_views_config_process_schema in Configuration Views 8

Same name and namespace in other branches
  1. 2.0.x config_views.views.inc \_views_views_config_process_schema()

Process all config definitions.

Parameters

array $views_config_data: Views config data structure.

array $all_definitions: All config definitions.

array $all_definitions_keys: All config definition keys.

array $definition: The current definition.

string $prefix: A prefix.

1 call to _views_views_config_process_schema()
config_views_views_data in ./config_views.views.inc
Implements hook_views_data().

File

./config_views.views.inc, line 95
Provide views data for dblog.module.

Code

function _views_views_config_process_schema(array &$views_config_data, array $all_definitions, array $all_definitions_keys, array $definition, $prefix = '') {
  if (!is_array($definition)) {
    return;
  }
  $delimiter = $prefix ? '.' : '';
  if (isset($definition['type'])) {
    if (is_array($definition['type'])) {
      return;
    }
    $type = $definition['type'];

    // The type might be constant (for eg. type: views_display) or might be a
    // reference, for eg. type: views.field.[plugin_id] As it is impossible to
    // know just from the metadata what the exact type will end up in the
    // latter case, iterate over every possibility (views.field.boolean,
    // views.field.counter, etc).
    if (isset($all_definitions[$type])) {
      $new_definition = $all_definitions[$type];
      if (isset($new_definition['type'])) {
        _views_views_config_process_schema($views_config_data, $all_definitions, $all_definitions_keys, $new_definition, $prefix);
      }
      elseif (!isset($definition['mapping']) && !isset($definition['sequence']) && isset($definition['label'])) {
        _views_views_config_data_add($views_config_data, $definition, $prefix);

        // As there is no mapping or sequence, this prefix is done.
        return;
      }
    }
    else {

      // For field.[%parent.type].settings, find field.email.settings etc.
      // For this, create a PCRE mask replacing the [] with "any string" for eg.
      // field\..*\.settings.
      $left = substr($type, 0, strpos($type, '['));
      $right = substr($type, strpos($type, ']') + 1);
      $mask = str_replace('.', '\\.', $left) . '.*' . str_replace('.', '\\.', $right);

      // Now find every possible type and recurse.
      foreach (preg_grep('/^' . $mask . '/', $all_definitions_keys) as $key) {
        _views_views_config_process_schema($views_config_data, $all_definitions, $all_definitions_keys, $all_definitions[$key], $prefix);
      }
    }
  }

  // Finished with the type-related recursions, now do the specific recursions.
  if (isset($definition['mapping'])) {
    foreach ($definition['mapping'] as $k => $new_definition) {
      _views_views_config_process_schema($views_config_data, $all_definitions, $all_definitions_keys, $new_definition, "{$prefix}{$delimiter}{$k}");
    }
  }
  elseif (isset($definition['sequence'])) {
    foreach ($definition['sequence'] as $new_definition) {
      if (!is_array($new_definition)) {
        continue;
      }
      _views_views_config_process_schema($views_config_data, $all_definitions, $all_definitions_keys, $new_definition, "{$prefix}{$delimiter}*");
    }
  }
}