本文整理汇总了PHP中Doctrine\DBAL\Connection::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getEventManager方法的具体用法?PHP Connection::getEventManager怎么用?PHP Connection::getEventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::getEventManager方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createInstance
/**
* 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());
}
示例2: _getConnection
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;
}
示例3: _getConnection
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;
}
示例4: testEventManagerPassedToPlatform
public function testEventManagerPassedToPlatform()
{
$this->assertInstanceOf('Doctrine\\Common\\EventManager', $this->_conn->getDatabasePlatform()->getEventManager());
$this->assertSame($this->_conn->getEventManager(), $this->_conn->getDatabasePlatform()->getEventManager());
}
示例5: __construct
/**
* @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;
}
示例6: getDbMockBuilder
private function getDbMockBuilder(Connection $db)
{
return $this->getMockBuilder('\\Doctrine\\DBAL\\Connection')->setConstructorArgs([$db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager()])->enableOriginalConstructor();
}
示例7: testGetEventManager
public function testGetEventManager()
{
$this->assertType('Doctrine\\Common\\EventManager', $this->_conn->getEventManager());
}
示例8: addDbEventSubscribers
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);
}
}
}
示例9: connectToDatabase
private function connectToDatabase(Connection $db, $databaseName)
{
$db->close();
$db->__construct(['dbname' => $databaseName] + $db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager());
$db->connect();
}
示例10:
function __construct(Connection $connection, KernelInterface $kernel)
{
$connection->getEventManager()->addEventListener(array(Events::postPersist, Events::postUpdate, Events::postRemove), $this);
$this->uploadDir = $kernel->getRootDir() . '/../web/uploads';
}
示例11: testEventManagerPassedToPlatform
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());
}