/** * Listener for column definition events. This intercepts definitions * for custom doctrine types and builds the appropriate Column Object. * * @param \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs $event * @throws \Doctrine\DBAL\DBALException */ public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $event) { $tableColumn = $event->getTableColumn(); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $dbType = $this->getDatabaseType($tableColumn['type']); if ($dbType !== 'enum' && $dbType !== 'set') { return; } $column = $this->getEnumerationTableColumnDefinition($tableColumn, $event->getDatabasePlatform()); $event->setColumn($column); $event->preventDefault(); }
public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $args) { $tableColumn = array_change_key_case($args->getTableColumn(), CASE_LOWER); $table = $args->getTable(); $info = null; if ('geometry' === $tableColumn['type']) { $info = $this->schemaManager->getGeometrySpatialColumnInfo($table, $tableColumn['field']); } elseif ('geography' === $tableColumn['type']) { $info = $this->schemaManager->getGeographySpatialColumnInfo($table, $tableColumn['field']); } if (!$info) { return; } $default = null; if (isset($tableColumn['default']) && 'NULL::geometry' !== $tableColumn['default'] && 'NULL::geography' !== $tableColumn['default']) { $default = $tableColumn['default']; } $options = array('notnull' => (bool) $tableColumn['isnotnull'], 'default' => $default, 'primary' => (bool) ($tableColumn['pri'] == 't'), 'comment' => isset($tableColumn['comment']) ? $tableColumn['comment'] : null); $column = new Column($tableColumn['field'], PostGISType::getType($tableColumn['type']), $options); $column->setCustomSchemaOption('geometry_type', $info['type'])->setCustomSchemaOption('srid', $info['srid']); $args->setColumn($column)->preventDefault(); }