Skip to content

Commit

Permalink
Fix dbal deprecation of passing unknown options to a Column
Browse files Browse the repository at this point in the history
  • Loading branch information
simonberger committed Oct 16, 2021
1 parent a469195 commit 0ba28a6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/EventListener/CreateSchemaListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace SimpleThings\EntityAudit\EventListener;

use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Types;
Expand Down Expand Up @@ -83,10 +84,13 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs)
);

foreach ($entityTable->getColumns() as $column) {
$revisionTable->addColumn($column->getName(), $column->getType()->getName(), array_merge(
$column->toArray(),
['notnull' => false, 'autoincrement' => false]
));
$columnOptions = array_filter($column->toArray(), static function($columnOption, $columnKey) {
return method_exists(Column::class, 'set'.$columnKey);
}, ARRAY_FILTER_USE_BOTH);
$columnOptions['notnull'] = false;
$columnOptions['autoincrement'] = false;

$revisionTable->addColumn($column->getName(), $column->getType()->getName(), $columnOptions);
}
$revisionTable->addColumn($this->config->getRevisionFieldName(), $this->config->getRevisionIdFieldType());
$revisionTable->addColumn($this->config->getRevisionTypeFieldName(), Types::STRING, ['length' => 4]);
Expand Down

0 comments on commit 0ba28a6

Please sign in to comment.