Created
March 26, 2013 23:25
-
-
Save j/5250228 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* Changes the class metadata databases to the test database. | |
* | |
* @author Jordan Stout <[email protected]> | |
*/ | |
final class ChangeDatabaseEventListener | |
{ | |
private $database; | |
public function __construct($database) | |
{ | |
$this->database = $database; | |
} | |
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) | |
{ | |
$metadata = $eventArgs->getClassMetadata(); | |
if ($this->database === ($database = $metadata->getDatabase()) || null === $database) { | |
return; | |
} | |
$metadata->setCollection($database.'.'.$metadata->getCollection()); | |
$metadata->setDatabase($this->database); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment