-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
onMigrationsQueryExecuting
and onMigrationsQueryExecuted
events
- Loading branch information
1 parent
ab7ebf3
commit 0b4dded
Showing
9 changed files
with
300 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
lib/Doctrine/Migrations/Event/MigrationsQueryEventArgs.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Event; | ||
|
||
use Doctrine\Common\EventArgs; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\Migrations\Metadata\MigrationPlan; | ||
use Doctrine\Migrations\MigratorConfiguration; | ||
use Doctrine\Migrations\Query\Query; | ||
|
||
/** | ||
* The MigrationsQueryEventArgs class is passed to events related to a single migration query from a version. | ||
*/ | ||
final class MigrationsQueryEventArgs extends EventArgs | ||
{ | ||
/** @var Connection */ | ||
private $connection; | ||
|
||
/** @var MigrationPlan */ | ||
private $plan; | ||
|
||
/** @var MigratorConfiguration */ | ||
private $migratorConfiguration; | ||
|
||
/** @var Query */ | ||
private $query; | ||
|
||
public function __construct( | ||
Connection $connection, | ||
MigrationPlan $plan, | ||
MigratorConfiguration $migratorConfiguration, | ||
Query $query | ||
) { | ||
$this->connection = $connection; | ||
$this->plan = $plan; | ||
$this->migratorConfiguration = $migratorConfiguration; | ||
$this->query = $query; | ||
} | ||
|
||
public function getConnection() : Connection | ||
{ | ||
return $this->connection; | ||
} | ||
|
||
public function getPlan() : MigrationPlan | ||
{ | ||
return $this->plan; | ||
} | ||
|
||
public function getMigratorConfiguration() : MigratorConfiguration | ||
{ | ||
return $this->migratorConfiguration; | ||
} | ||
|
||
public function getQuery() : Query | ||
{ | ||
return $this->query; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Query; | ||
|
||
/** | ||
* The Query wraps the sql query, parameters and types. It used in MigrationsQueryEventArgs. | ||
*/ | ||
final class Query | ||
{ | ||
/** @var string */ | ||
private $queryString; | ||
|
||
/** @var mixed[] */ | ||
private $parameters; | ||
|
||
/** @var mixed[] */ | ||
private $types; | ||
|
||
/** | ||
* @param mixed[] $parameters | ||
* @param mixed[] $types | ||
*/ | ||
public function __construct(string $queryString, array $parameters = [], array $types = []) | ||
{ | ||
$this->queryString = $queryString; | ||
$this->parameters = $parameters; | ||
$this->types = $types; | ||
} | ||
|
||
public function getQueryString() : string | ||
{ | ||
return $this->queryString; | ||
} | ||
|
||
/** @return mixed[] */ | ||
public function getParameters() : array | ||
{ | ||
return $this->parameters; | ||
} | ||
|
||
/** @return mixed[] */ | ||
public function getTypes() : array | ||
{ | ||
return $this->types; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Tests\Query; | ||
|
||
use Doctrine\Migrations\Query\Query; | ||
use Doctrine\Migrations\Tests\MigrationTestCase; | ||
|
||
final class QueryTest extends MigrationTestCase | ||
{ | ||
public function testGetQuery() : void | ||
{ | ||
$query = new Query('foo', ['bar', 'baz'], ['qux', 'quux']); | ||
|
||
self::assertSame('foo', $query->getQueryString()); | ||
self::assertSame(['bar', 'baz'], $query->getParameters()); | ||
self::assertSame(['qux', 'quux'], $query->getTypes()); | ||
} | ||
} |
Oops, something went wrong.