You are here

public function DefaultController::schema_sql in Schema 8

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

File

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

Class

DefaultController
Default controller for the schema module.

Namespace

Drupal\schema\Controller

Code

public function schema_sql($engine = NULL) {
  $schema = schema_get_schema(TRUE);
  $sql = '';
  foreach ($schema as $name => $table) {
    if (substr($name, 0, 1) == '#') {
      continue;
    }
    if ($engine) {
      $stmts = call_user_func('schema_' . $engine . '_create_table_sql', $table);
    }
    else {
      $stmts = schema_dbobject()
        ->getCreateTableSql($name, $table);
    }
    $sql .= implode(";\n", $stmts) . ";\n\n";
  }
  return array(
    '#type' => 'textarea',
    '#rows' => 30,
    '#value' => $sql,
    '#attributes' => array(
      'style' => 'width:100%;',
    ),
  );
}