class TableComparisonInfoBuilder in Schema 8
Hierarchy
- class \Drupal\schema\Comparison\TableComparisonInfoBuilder
Expanded class hierarchy of TableComparisonInfoBuilder
File
- src/
Comparison/ TableComparisonInfoBuilder.php, line 18 - Contains Drupal\schema\Comparison\TableComparisonInfoBuilder.
Namespace
Drupal\schema\ComparisonView source
class TableComparisonInfoBuilder {
protected $o;
public function __construct(TableComparison $comparison) {
$this->o = $comparison;
}
public function getInfoArray() {
$reasons = array();
$notes = array();
if ($this->o
->isTableCommentDifferent()) {
$reasons[] = array(
'#markup' => 'Table comment is different.' . '<br/>declared: ' . $this->o
->getDeclaredTableComment() . '<br/>actual: ' . $this->o
->getActualTableComment(),
);
}
/** @var MissingColumn $column */
foreach ($this->o
->getMissingColumns() as $column) {
$reasons[] = sprintf("%s: not in database", $column
->getColumnName());
}
/** @var DifferentColumn $column */
foreach ($this->o
->getDifferentColumns() as $column) {
$colname = $column
->getColumnName();
$kdiffs = $column
->getDifferentKeys();
$reasons[] = array(
'#markup' => "column {$colname} - difference" . (count($kdiffs) > 1 ? 's' : '') . " on: " . implode(', ', $kdiffs) . "<br/>declared: " . schema_phpprint_column($column
->getDeclaredSchema()) . '<br/>actual: ' . schema_phpprint_column($column
->getActualSchema()),
);
}
/** @var ExtraColumn $column */
foreach ($this->o
->getExtraColumns() as $column) {
$reasons[] = sprintf("%s: unexpected column in database", $column
->getColumnName());
}
/** @var MissingIndex $index */
foreach ($this->o
->getMissingIndexes() as $index) {
$keyname = $index
->getIndexName();
$type = $index
->getType();
if ($index
->isPrimary()) {
$reasons[] = "primary key: missing in database";
}
else {
$reasons[] = "{$type} {$keyname}: missing in database";
}
}
/** @var DifferentIndex $index */
foreach ($this->o
->getDifferentIndexes() as $index) {
$type = $index
->getType();
$keyname = $index
->getIndexName();
if ($index
->isPrimary()) {
$reasons[] = array(
'#markup' => "{$type} {$keyname}:<br />declared: " . schema_phpprint_key($index
->getDeclaredSchema()) . '<br />actual: ' . schema_phpprint_key($index
->getActualSchema()),
);
}
else {
$reasons[] = array(
'#markup' => "primary key:<br />declared: " . schema_phpprint_key($index
->getDeclaredSchema()) . '<br />actual: ' . schema_phpprint_key($index
->getActualSchema()),
);
}
}
/** @var ExtraIndex $index */
foreach ($this->o
->getExtraIndexes() as $index) {
$keyname = $index
->getIndexName();
$type = $index
->getType();
if ($index
->isPrimary()) {
$reasons[] = "primary key: missing in schema";
}
else {
$notes[] = "{$type} {$keyname}: unexpected (not an error)";
}
}
return array(
'status' => $this->o
->isStatusDifferent() ? "different" : "same",
'reasons' => $reasons,
'notes' => $notes,
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TableComparisonInfoBuilder:: |
protected | property | ||
TableComparisonInfoBuilder:: |
public | function | ||
TableComparisonInfoBuilder:: |
public | function |