You are here

public function DefaultController::schema_inspect in Schema 8

1 string reference to 'DefaultController::schema_inspect'
schema.routing.yml in ./schema.routing.yml
schema.routing.yml

File

src/Controller/DefaultController.php, line 223
Contains \Drupal\schema\Controller\DefaultController.

Class

DefaultController
Default controller for the schema module.

Namespace

Drupal\schema\Controller

Code

public function schema_inspect() {
  $build = array();
  $schema = schema_get_schema(TRUE);
  $inspect = schema_dbobject()
    ->inspect();
  foreach ($inspect as $name => $table) {
    $module = isset($schema[$name]['module']) ? $schema[$name]['module'] : 'Unknown';
    if (!isset($build[$module])) {
      $build[$module] = array(
        '#type' => 'details',
        '#title' => $module,
      );
    }
    $build[$module][$name] = array(
      '#type' => 'textarea',
      '#rows' => 10,
      '#value' => schema_phpprint_table($name, $table),
      '#attributes' => array(
        'style' => 'width:100%;',
      ),
    );
  }

  // Sort by keys, i.e. the module name, then insert weights respectively.
  ksort($build);
  $i = 0;
  array_map(function ($v) use ($i) {
    if ($v['#title'] == 'Unknown') {
      $weight = -50;
    }
    else {
      $weight = $i++;
    }
    $v['#weight'] = $weight;
  }, $build);
  return $build;
}