Returns the field schema.
array The field schema, as an array of key/value pairs in the format returned by hook_field_schema():
Overrides FieldInterface::getSchema
public function getSchema() {
if (!isset($this->schema)) {
$module_handler = \Drupal::moduleHandler();
// Collect the schema from the field type.
// @todo Use $module_handler->loadInclude() once
// http://drupal.org/node/1941000 is fixed.
module_load_install($this->module);
// Invoke hook_field_schema() for the field.
$schema = (array) $module_handler
->invoke($this->module, 'field_schema', array(
$this,
));
$schema += array(
'columns' => array(),
'indexes' => array(),
'foreign keys' => array(),
);
// Check that the schema does not include forbidden column names.
if (array_intersect(array_keys($schema['columns']), static::getReservedColumns())) {
throw new FieldException('Illegal field type columns.');
}
// Merge custom indexes with those specified by the field type. Custom
// indexes prevail.
$schema['indexes'] = $this->indexes + $schema['indexes'];
$this->schema = $schema;
}
return $this->schema;
}