Gets the EventManager used by the Connection.
public getEventManager ( ) : Doctrine\Common\EventManager | ||
return | Doctrine\Common\EventManager |
/** * Factory method to create EntityManager instances. * * @param Connection $conn * @param Configuration $config * @param EventManager $eventManager * @throws \Doctrine\ORM\ORMException * @return ModelManager */ public static function createInstance(Connection $conn, Configuration $config, EventManager $eventManager = null) { if (!$config->getMetadataDriverImpl()) { throw ORMException::missingMappingDriverImpl(); } if ($eventManager !== null && $conn->getEventManager() !== $eventManager) { throw ORMException::mismatchedEventManager(); } return new self($conn, $config, $conn->getEventManager()); }
protected function _getConnection() { if (!isset(self::$_conn)) { self::$_conn = DriverManager::getConnection($this->_getDbParams(), new Configuration()); self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber()); Configurator::configure(self::$_conn->getConfiguration()); if (!Type::hasType('tsvector')) { Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType'); } $platform = self::$_conn->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('tsvector', 'tsvector'); } return self::$_conn; }
protected function _getConnection() { if (!isset(self::$_conn)) { $dbParams = array('driver' => $GLOBALS['db_type'], 'user' => $GLOBALS['db_username'], 'password' => $GLOBALS['db_password'], 'host' => $GLOBALS['db_host'], 'dbname' => $GLOBALS['db_name'], 'port' => $GLOBALS['db_port']); self::$_conn = DriverManager::getConnection($dbParams, new Configuration()); self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber()); Configurator::configure(self::$_conn->getConfiguration()); if (!Type::hasType('tsvector')) { Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType'); } $platform = self::$_conn->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('tsvector', 'tsvector'); } return self::$_conn; }
public function testEventManagerPassedToPlatform() { $this->assertInstanceOf('Doctrine\\Common\\EventManager', $this->_conn->getDatabasePlatform()->getEventManager()); $this->assertSame($this->_conn->getEventManager(), $this->_conn->getDatabasePlatform()->getEventManager()); }
/** * @param Connection $conn * @param string $generatorTableName */ public function __construct(Connection $conn, $generatorTableName = 'sequences') { $params = $conn->getParams(); if ($params['driver'] == 'pdo_sqlite') { throw new \Doctrine\DBAL\DBALException("Cannot use TableGenerator with SQLite."); } $this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager()); $this->generatorTableName = $generatorTableName; }
private function getDbMockBuilder(Connection $db) { return $this->getMockBuilder('\\Doctrine\\DBAL\\Connection')->setConstructorArgs([$db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager()])->enableOriginalConstructor(); }
public function testGetEventManager() { $this->assertType('Doctrine\\Common\\EventManager', $this->_conn->getEventManager()); }
private static function addDbEventSubscribers(Connection $conn) { if (isset($GLOBALS['db_event_subscribers'])) { $evm = $conn->getEventManager(); foreach (explode(",", $GLOBALS['db_event_subscribers']) as $subscriberClass) { $subscriberInstance = new $subscriberClass(); $evm->addEventSubscriber($subscriberInstance); } } }
private function connectToDatabase(Connection $db, $databaseName) { $db->close(); $db->__construct(['dbname' => $databaseName] + $db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager()); $db->connect(); }
function __construct(Connection $connection, KernelInterface $kernel) { $connection->getEventManager()->addEventListener(array(Events::postPersist, Events::postUpdate, Events::postRemove), $this); $this->uploadDir = $kernel->getRootDir() . '/../web/uploads'; }
public function testEventManagerPassedToPlatform() { $driverMock = new DriverMock(); $connection = new Connection($this->params, $driverMock); $this->assertInstanceOf('Doctrine\\Common\\EventManager', $connection->getDatabasePlatform()->getEventManager()); $this->assertSame($connection->getEventManager(), $connection->getDatabasePlatform()->getEventManager()); }