Commit 6abba72f authored by jsor's avatar jsor

Rename alter table events

parent b51762cd
......@@ -35,7 +35,7 @@ use Doctrine\Common\EventArgs,
* @version $Revision$
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableAddedColumnEventArgs extends SchemaEventArgs
class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
{
/**
* @var Column
......
......@@ -35,7 +35,7 @@ use Doctrine\Common\EventArgs,
* @version $Revision$
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableChangedColumnEventArgs extends SchemaEventArgs
class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
{
/**
* @var ColumnDiff
......
......@@ -35,7 +35,7 @@ use Doctrine\Common\EventArgs,
* @version $Revision$
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableRemovedColumnEventArgs extends SchemaEventArgs
class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
{
/**
* @var Column
......
......@@ -35,7 +35,7 @@ use Doctrine\Common\EventArgs,
* @version $Revision$
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableRenamedColumnEventArgs extends SchemaEventArgs
class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
{
/**
* @var string
......
......@@ -38,9 +38,9 @@ final class Events
const onSchemaCreateTable = 'onSchemaCreateTable';
const onSchemaCreateTableColumn = 'onSchemaCreateTableColumn';
const onSchemaDropTable = 'onSchemaDropTable';
const onSchemaAlterTableAddedColumn = 'onSchemaAlterTableAddedColumn';
const onSchemaAlterTableRemovedColumn = 'onSchemaAlterTableRemovedColumn';
const onSchemaAlterTableChangedColumn = 'onSchemaAlterTableChangedColumn';
const onSchemaAlterTableRenamedColumn = 'onSchemaAlterTableRenamedColumn';
const onSchemaAlterTableAddColumn = 'onSchemaAlterTableAddColumn';
const onSchemaAlterTableRemoveColumn = 'onSchemaAlterTableRemoveColumn';
const onSchemaAlterTableChangeColumn = 'onSchemaAlterTableChangeColumn';
const onSchemaAlterTableRenameColumn = 'onSchemaAlterTableRenameColumn';
const onSchemaColumnDefinition = 'onSchemaColumnDefinition';
}
......@@ -22,10 +22,10 @@ namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\TableDiff,
Doctrine\DBAL\Schema\Table,
Doctrine\DBAL\Events,
Doctrine\DBAL\Event\SchemaAlterTableAddedColumnEventArgs,
Doctrine\DBAL\Event\SchemaAlterTableRemovedColumnEventArgs,
Doctrine\DBAL\Event\SchemaAlterTableChangedColumnEventArgs,
Doctrine\DBAL\Event\SchemaAlterTableRenamedColumnEventArgs;
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs,
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs,
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs,
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs;
/**
* PostgreSqlPlatform.
......@@ -388,9 +388,9 @@ class PostgreSqlPlatform extends AbstractPlatform
$columnSql = array();
foreach ($diff->addedColumns as $column) {
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableAddedColumn)) {
$eventArgs = new SchemaAlterTableAddedColumnEventArgs($column, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableAddedColumn, $eventArgs);
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableAddColumn)) {
$eventArgs = new SchemaAlterTableAddColumnEventArgs($column, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableAddColumn, $eventArgs);
$columnSql = array_merge($columnSql, $eventArgs->getSql());
......@@ -407,9 +407,9 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach ($diff->removedColumns as $column) {
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableRemovedColumn)) {
$eventArgs = new SchemaAlterTableRemovedColumnEventArgs($column, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableRemovedColumn, $eventArgs);
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableRemoveColumn)) {
$eventArgs = new SchemaAlterTableRemoveColumnEventArgs($column, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableRemoveColumn, $eventArgs);
$columnSql = array_merge($columnSql, $eventArgs->getSql());
......@@ -423,9 +423,9 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach ($diff->changedColumns AS $columnDiff) {
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableChangedColumn)) {
$eventArgs = new SchemaAlterTableChangedColumnEventArgs($columnDiff, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableChangedColumn, $eventArgs);
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableChangeColumn)) {
$eventArgs = new SchemaAlterTableChangeColumnEventArgs($columnDiff, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableChangeColumn, $eventArgs);
$columnSql = array_merge($columnSql, $eventArgs->getSql());
......@@ -473,9 +473,9 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach ($diff->renamedColumns as $oldColumnName => $column) {
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableRenamedColumn)) {
$eventArgs = new SchemaAlterTableRenamedColumnEventArgs($oldColumnName, $column, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableRenamedColumn, $eventArgs);
if (null !== $this->_eventManager && $this->_eventManager->hasListeners(Events::onSchemaAlterTableRenameColumn)) {
$eventArgs = new SchemaAlterTableRenameColumnEventArgs($oldColumnName, $column, $diff, $this);
$this->_eventManager->dispatchEvent(Events::onSchemaAlterTableRenameColumn, $eventArgs);
$columnSql = array_merge($columnSql, $eventArgs->getSql());
......
......@@ -219,32 +219,32 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testGetAlterTableSqlDispatchEvent()
{
$events = array(
'onSchemaAlterTableAddedColumn',
'onSchemaAlterTableRemovedColumn',
'onSchemaAlterTableChangedColumn',
'onSchemaAlterTableRenamedColumn'
'onSchemaAlterTableAddColumn',
'onSchemaAlterTableRemoveColumn',
'onSchemaAlterTableChangeColumn',
'onSchemaAlterTableRenameColumn'
);
$listenerMock = $this->getMock('GetAlterTableSqlDispatchEvenListener', $events);
$listenerMock
->expects($this->once())
->method('onSchemaAlterTableAddedColumn');
->method('onSchemaAlterTableAddColumn');
$listenerMock
->expects($this->once())
->method('onSchemaAlterTableRemovedColumn');
->method('onSchemaAlterTableRemoveColumn');
$listenerMock
->expects($this->once())
->method('onSchemaAlterTableChangedColumn');
->method('onSchemaAlterTableChangeColumn');
$listenerMock
->expects($this->once())
->method('onSchemaAlterTableRenamedColumn');
->method('onSchemaAlterTableRenameColumn');
$eventManager = new EventManager();
$events = array(
Events::onSchemaAlterTableAddedColumn,
Events::onSchemaAlterTableRemovedColumn,
Events::onSchemaAlterTableChangedColumn,
Events::onSchemaAlterTableRenamedColumn
Events::onSchemaAlterTableAddColumn,
Events::onSchemaAlterTableRemoveColumn,
Events::onSchemaAlterTableChangeColumn,
Events::onSchemaAlterTableRenameColumn
);
$eventManager->addEventListener($events, $listenerMock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment