Created
March 29, 2011 13:55
-
-
Save dmdeller/892404 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace gadgetron\doctrine; | |
use Doctrine\ORM\Events; | |
class EventSubscriber implements \Doctrine\Common\EventSubscriber | |
{ | |
public function getSubscribedEvents() | |
{ | |
return array(Events::loadClassMetadata); | |
} | |
public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs) | |
{ | |
$metadata = $eventArgs->getClassMetadata(); | |
// if no custom repository is specified in annotations, use project base repository | |
if (empty($metadata->customRepositoryClassName)) | |
{ | |
$metadata->customRepositoryClassName = 'gadgetron\doctrine\EntityRepository'; | |
} | |
} | |
} |
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
<?php | |
// ... | |
// Create EventManager | |
$eventManager = new EventManager(); | |
$eventManager->addEventSubscriber(new \gadgetron\doctrine\EventSubscriber()); | |
// Create EntityManager | |
$entityManager = EntityManager::create($connectionOptions, $config, $eventManager); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment