function Table::validate

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

Validates the properties of the value object.

Throws

\Drupal\Core\Database\Exception\SchemaDefinitionException

1 call to Table::validate()
Table::__construct in core/lib/Drupal/Core/Database/SchemaDefinition/Table.php
Constructor.

File

core/lib/Drupal/Core/Database/SchemaDefinition/Table.php, line 64

Class

Table
Describes a database table.

Namespace

Drupal\Core\Database\SchemaDefinition

Code

private function validate() : void {
  if ($this->columns && !Inspector::assertAllObjects($this->columns, Column::class)) {
    throw new SchemaDefinitionException("All members of the 'columns' argument of the '{$this->name}' Table must be Column objects");
  }
  if ($this->uniqueKeys && !Inspector::assertAllObjects($this->uniqueKeys, UniqueKey::class)) {
    throw new SchemaDefinitionException("All members of the 'uniqueKeys' argument of the '{$this->name}' Table must be UniqueKey objects");
  }
  if ($this->indexes && !Inspector::assertAllObjects($this->indexes, Index::class)) {
    throw new SchemaDefinitionException("All members of the 'indexes' argument of the '{$this->name}' Table must be Index objects");
  }
  if ($this->foreignKeys && !Inspector::assertAllObjects($this->foreignKeys, ForeignKey::class)) {
    throw new SchemaDefinitionException("All members of the 'foreignKeys' argument of the '{$this->name}' Table must be ForeignKey objects");
  }
}

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