W3cubDocs

/Drupal 8

function _drupal_schema_initialize

_drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE)

Fills in required default values for table definitions from hook_schema().

Parameters

array $schema: The schema definition array as it was returned by the module's hook_schema().

string $module: The module for which hook_schema() was invoked.

bool $remove_descriptions: (optional) Whether to additionally remove 'description' keys of all tables and fields to improve performance of serialize() and unserialize(). Defaults to TRUE.

Related topics

Schema API
API to handle database schemas.

File

core/includes/schema.inc, line 186
Schema API handling functions.

Code

function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
  // Set the name and module key for all tables.
  foreach ($schema as $name => &$table) {
    if (empty($table['module'])) {
      $table['module'] = $module;
    }
    if (!isset($table['name'])) {
      $table['name'] = $name;
    }
    if ($remove_descriptions) {
      unset($table['description']);
      foreach ($table['fields'] as &$field) {
        unset($field['description']);
      }
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!schema.inc/function/_drupal_schema_initialize/8.1.x