function KeyBase::toArray

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Database/SchemaDefinition/KeyBase.php \Drupal\Core\Database\SchemaDefinition\KeyBase::toArray()

Converts the object to legacy array-based specifications.

@internal

Return value

array The legacy array-based specification.

Overrides SchemaDefinitionInterface::toArray

1 method overrides KeyBase::toArray()
ForeignKey::toArray in core/lib/Drupal/Core/Database/SchemaDefinition/ForeignKey.php
Converts the object to legacy array-based specifications.

File

core/lib/Drupal/Core/Database/SchemaDefinition/KeyBase.php, line 80

Class

KeyBase
Base class for table keys (primary, unique, index).

Namespace

Drupal\Core\Database\SchemaDefinition

Code

public function toArray() : array {
  $spec = [];
  foreach ($this->columns as $keyColumn) {
    $spec[] = $keyColumn->length !== NULL ? [
      $keyColumn->name,
      $keyColumn->length,
    ] : $keyColumn->name;
  }
  return $spec;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.