You are here

config_views.module in Configuration Views 8

Same filename and directory in other branches
  1. 2.0.x config_views.module

Contains Config Views implementation.

File

config_views.module
View source
<?php

/**
 * @file
 * Contains Config Views implementation.
 */
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_FORM_ID_alter().
 */
function config_views_form_view_add_form_alter(&$form, FormStateInterface $form_state) {
  $options = [];
  foreach ($form['displays']['show']['wizard_key']['#options'] as $key => $option) {
    $group = 'Content';
    if (strpos($key, 'standard:') === 0 || strpos($key, 'config_views') === 0) {
      $group = 'Configuration';
    }
    $options[$group][$key] = $option;
  }

  // Order by label, instead of key.
  if (is_array($options['Content'])) {
    uasort($options['Content'], function ($a, $b) {
      return $a
        ->render() > $b
        ->render();
    });
  }

  // Order by label, instead of key.
  if (is_array($options['Content'])) {
    uasort($options['Configuration'], function ($a, $b) {
      return $a
        ->render() > $b
        ->render();
    });
  }
  $form['displays']['show']['wizard_key']['#options'] = $options;
}