protected function setUp() { parent::setUp(); if (!Type::hasType('point')) { Type::addType('point', 'Doctrine\\Tests\\Types\\MySqlPointType'); } }
public static function setUpBeforeClass() { Type::addType('CarbonDate', 'DoctrineExtensions\\Types\\CarbonDateType'); Type::addType('CarbonDateTime', 'DoctrineExtensions\\Types\\CarbonDateTimeType'); Type::addType('CarbonDateTimeTz', 'DoctrineExtensions\\Types\\CarbonDateTimeTzType'); Type::addType('CarbonTime', 'DoctrineExtensions\\Types\\CarbonTimeType'); }
/** * Adds doctrine point type * * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); if (null === $classMetadata->reflClass) { return; } if ($this->isGeocodable($classMetadata)) { if (!Type::hasType('point')) { Type::addType('point', 'Knp\\DoctrineBehaviors\\DBAL\\Types\\PointType'); } $em = $eventArgs->getEntityManager(); $con = $em->getConnection(); // skip non-postgres platforms if (!$con->getDatabasePlatform() instanceof PostgreSqlPlatform && !$con->getDatabasePlatform() instanceof MySqlPlatform) { return; } // skip platforms with registerd stuff if (!$con->getDatabasePlatform()->hasDoctrineTypeMappingFor('point')) { $con->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point'); if ($con->getDatabasePlatform() instanceof PostgreSqlPlatform) { $em->getConfiguration()->addCustomNumericFunction('DISTANCE', 'Knp\\DoctrineBehaviors\\ORM\\Geocodable\\Query\\AST\\Functions\\DistanceFunction'); } } $classMetadata->mapField(['fieldName' => 'location', 'type' => 'point', 'nullable' => true]); } }
protected function setUp() { if (!Type::hasType(PercentType::TYPE)) { Type::addType(PercentType::TYPE, 'Oro\\DBAL\\Types\\PercentType'); } $this->percentType = Type::getType(PercentType::TYPE); }
public function boot() { if (!Type::hasType('string_simple_array')) { // this should be optional if using a different ORM Type::addType('string_simple_array', 'Giosh94mhz\\GeonamesBundle\\Doctrine\\Types\\StringSimpleArrayType'); } }
public function __construct($setConfigFiles = true) { if ($setConfigFiles) { $this->configFile = __DIR__ . '/../../../config.php'; $this->localConfigFile = __DIR__ . '/../../../config.local.php'; } parent::__construct(); $isDevMode = false; $cache = new \Doctrine\Common\Cache\FilesystemCache(__DIR__ . '/../../tmp'); $config = Setup::createConfiguration($isDevMode, __DIR__ . '/../../tmp', $cache); $config->setProxyDir(__DIR__ . '/../../tmp'); $config->setProxyNamespace('MyProject\\Proxies'); $config->setAutoGenerateProxyClasses(true); $paths = [__DIR__ . '/../Entity']; $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new AnnotationReader(), $paths); \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists'); $config->setMetadataDriverImpl($driver); //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); $conn = ['driver' => 'mysqli', 'host' => '127.0.0.1', 'user' => $this->databaseFactory->getUserName(), 'password' => $this->databaseFactory->getPassword(), 'dbname' => $this->databaseFactory->getDatabaseName()]; $this->entityManager = EntityManager::create($conn, $config); $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); \Doctrine\DBAL\Types\Type::addType('enum', StringType::class); $this->entityManager->getConfiguration()->addCustomStringFunction('DATE', DateFunction::class); $this->user = $this->entityManager->createQueryBuilder()->select('u')->from(Sources\Tests\Entity\User::class, 'u'); }
public function setUp() { // register our custom type if (!Type::hasType('hstore')) { Type::addType('hstore', 'EasyBib\\Doctrine\\Types\\Hstore'); } $isDevMode = true; $doctrineConfig = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/Entity'), $isDevMode); // database configuration parameters $rootTestsFolder = dirname(dirname(dirname(dirname(__DIR__)))); $this->isTravis = getenv("TRAVIS"); if (file_exists($rootTestsFolder . '/db-config.php')) { $dbConfig = (include $rootTestsFolder . '/db-config.php'); } elseif (false !== $this->isTravis) { $dbConfig = (include $rootTestsFolder . '/db-config-travisci.php'); } else { throw new \RuntimeException("No database configuration found."); } // create the entity manager $this->em = EntityManager::create($dbConfig, $doctrineConfig); // enable 'hstore' $this->em->getConnection()->exec("CREATE EXTENSION IF NOT EXISTS hstore"); // register type with DBAL $this->em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('hstore', 'hstore'); // make the PersistentObject happy PersistentObject::setObjectManager($this->em); // create table $this->setUpSchema($this->em); }
protected function setUp() { parent::setUp(); if (!Type::hasType('bigfloat')) { Type::addType('bigfloat', '\\Psql\\Doctrine\\DBAL\\Types\\BigFloatType'); } }
public static function setUpBeforeClass() { Type::addType('CarbonDate', 'BespokeSupport\\DoctrineTypeCarbon\\CarbonDateType'); Type::addType('CarbonDateTime', 'BespokeSupport\\DoctrineTypeCarbon\\CarbonDateTimeType'); Type::addType('CarbonDateTimeTimezone', 'BespokeSupport\\DoctrineTypeCarbon\\CarbonDateTimeTimezoneType'); Type::addType('CarbonTime', 'BespokeSupport\\DoctrineTypeCarbon\\CarbonTimeType'); }
/** * @param ApplicationInterface $app * * @throws \Doctrine\ORM\ORMException * @throws \ObjectivePHP\Primitives\Exception * @throws \ObjectivePHP\ServicesFactory\Exception */ public function buildEntityManagers(ApplicationInterface $app) { $entityManagers = $app->getConfig()->subset(Config\EntityManager::class); foreach ($entityManagers as $connection => $params) { if (isset($params['db'])) { $params = $params['db']; } // normalize if needed $entitiesPaths = $params['entities.locations']; Collection::cast($entitiesPaths)->each(function (&$path) { if (strpos($path, '/') !== 0) { $path = getcwd() . '/' . $path; } }); // TODO: handle isDev depending on app config $emConfig = Setup::createAnnotationMetadataConfiguration((array) $entitiesPaths, true); $emConfig->setNamingStrategy(new UnderscoreNamingStrategy()); $em = EntityManager::create($params, $emConfig); if (!empty($params['mapping_types']) && is_array($params['mapping_types'])) { $platform = $em->getConnection()->getDatabasePlatform(); foreach ($params['mapping_types'] as $type => $mapping) { if (!Type::hasType($type) && class_exists($mapping)) { Type::addType($type, $mapping); $mapping = $type; } $platform->registerDoctrineTypeMapping($type, $mapping); } } // register entity manager as a service $emServiceId = 'doctrine.em.' . Str::cast($connection)->lower(); $app->getServicesFactory()->registerService(['id' => $emServiceId, 'instance' => $em]); $app->getServicesFactory()->registerService(['id' => 'db.connection.' . $connection, 'instance' => $em->getConnection()->getWrappedConnection()]); } }
function doctrineInit($cachedAnnotationReader) { $evm = new Doctrine\Common\EventManager(); bootstrapAddTreeExtension($evm, $cachedAnnotationReader); Type::addType('mediainfotype', 'Uppu4\\Type\\MediaInfoType'); return $evm; }
public function boot() { $em = $this->container->get("doctrine.orm.entity_manager"); try { Registry::getInstance("app"); } catch (InvalidArgumentException $e) { Registry::addLogger($this->container->get("logger"), "app"); } try { Type::addType("encryptedstring", "\\Keboola\\ProvisioningBundle\\Types\\EncryptedStringType"); Type::addType("enumservertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumServerTypeType"); Type::addType("enumservermode", "\\Keboola\\ProvisioningBundle\\Types\\EnumServerModeType"); Type::addType("enumaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumAccountTypeType"); Type::addType("enumwrdbaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumWrdbAccountTypeType"); Type::addType("enumredshiftaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftAccountTypeType"); Type::addType("enumsnowflakeaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountTypeType"); Type::addType("enumsnowflakeaccountwithluckyguesstype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountWithLuckyguessTypeType"); Type::addType("enumsnowflakeaccountwithluckyguessandwritertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountWithLuckyguessAndWriterTypeType"); Type::addType("enumredshiftworkspaceaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountTypeType"); Type::addType("enumdockeraccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumDockerAccountTypeType"); Type::addType("enumredshiftworkspaceaccountwithluckyguestype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountWithLuckyguessTypeType"); Type::addType("enumredshiftworkspaceaccountwithluckyguessandwritertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountWithLuckyguessAndWriterTypeType"); $encryptor = new AesEncryptor($this->container->getParameter("provisioning_api.key")); // 256 bit key EncryptedStringType::setEncryptor($encryptor); $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping("encryptedstring", "encryptedstring"); } catch (\Doctrine\DBAL\DBALException $e) { // For some reason this exception gets thrown during // the clearing of the cache. I didn't have time to // find out why :-) } }
/** * @param EventInterface $e */ public function onBootstrap(EventInterface $e) { $serviceManager = $e->getApplication()->getServiceManager(); $config = $serviceManager->get('Config'); // $eventManager = $e->getApplication()->getEventManager(); // route matching $eventManager->attach($serviceManager->get('Msingi\\Cms\\Event\\RouteListener')); // determine locale $eventManager->attach($serviceManager->get('Msingi\\Cms\\Event\\LocaleListener')); // http processing $eventManager->attach($serviceManager->get('Msingi\\Cms\\Event\\HttpListener')); $this->initLayouts($e); // Enable using of enum fields with Doctrine ORM /** @var \Doctrine\ORM\EntityManager $entityManager */ $entityManager = $serviceManager->get('Doctrine\\ORM\\EntityManager'); $platform = $entityManager->getConnection()->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('enum', 'string'); // Register enum types if (isset($config['doctrine']['enums'])) { foreach ($config['doctrine']['enums'] as $enum => $className) { Type::addType($enum, $className); } } // $eventManager = $entityManager->getEventManager(); $eventManager->addEventListener(array(\Doctrine\ORM\Events::postLoad), new InjectListener($serviceManager)); }
public function setUp() { if (!Type::hasType('point')) { Type::addType('point', 'CrEOF\\Spatial\\DBAL\\Types\\Geometry\\PointType'); } parent::setUp(); }
public function boot() { if (!Type::hasType('branch_logo')) { Type::addType('branch_logo', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\BranchLogoType'); } if (!Type::hasType('priority')) { Type::addType('priority', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketPriorityType'); } if (!Type::hasType('file')) { Type::addType('file', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\AttachmentFileType'); } if (!Type::hasType('status')) { Type::addType('status', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketStatusType'); } if (!Type::hasType('source')) { Type::addType('source', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSourceType'); } if (!Type::hasType('ticket_sequence_number')) { Type::addType('ticket_sequence_number', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSequenceNumberType'); } if (!Type::hasType('ticket_unique_id')) { Type::addType('ticket_unique_id', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketUniqueIdType'); } foreach ($this->dataAuditTypes as $type) { if (!AuditFieldTypeRegistry::hasType($type)) { AuditFieldTypeRegistry::addType($type, $type); } } $em = $this->container->get('doctrine.orm.default_entity_manager'); $conn = $em->getConnection(); $conn->getDatabasePlatform()->registerDoctrineTypeMapping('FILE', 'string'); }
public function __construct() { //TODO its not fine if (!Type::hasType('genderEnumType')) { Type::addType('genderEnumType', 'Network\\StoreBundle\\DBAL\\GenderEnumType'); } if (!Type::hasType('roleEnumType')) { Type::addType('roleEnumType', 'Network\\StoreBundle\\DBAL\\RoleEnumType'); } if (!Type::hasType('relationshipStatusEnumType')) { Type::addType('relationshipStatusEnumType', 'Network\\StoreBundle\\DBAL\\RelationshipStatusEnumType'); } if (!Type::hasType('roleCommunityEnumType')) { Type::addType('roleCommunityEnumType', 'Network\\StoreBundle\\DBAL\\RoleCommunityEnumType'); } if (!Type::hasType('viewCommunityEnumType')) { Type::addType('viewCommunityEnumType', 'Network\\StoreBundle\\DBAL\\ViewCommunityEnumType'); } if (!Type::hasType('typeCommunityEnumType')) { Type::addType('typeCommunityEnumType', 'Network\\StoreBundle\\DBAL\\TypeCommunityEnumType'); } if (!Type::hasType('threadEnumType')) { Type::addType('threadEnumType', 'Network\\StoreBundle\\DBAL\\ThreadEnumType'); } if (!Type::hasType('typePostEnumType')) { Type::addType('typePostEnumType', 'Network\\StoreBundle\\DBAL\\TypePostEnumType'); } }
protected function setUp() { parent::setUp(); Type::addType(DDC2012TsVectorType::MYTYPE, __NAMESPACE__ . '\\DDC2012TsVectorType'); DDC2012TsVectorType::$calls = array(); $this->_schemaTool->createSchema(array($this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC2012Item'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC2012ItemPerson'))); }
public static function getEntityManager($smart = FALSE, $path_to_entity = null, $proxyPath = null, $proxyNamespace = null) { if (empty(self::$em)) { if ($path_to_entity === NULL) { //$path_to_entity = PATH_ROOT . '/' . Sokol::getApp()->name . '/Entity'; $path_to_entity = PATH_ROOT . '/Entity'; } $isDev = Sokol::getApp()->isDev; $connectionParams = Sokol::getConfig('db'); //---Table Prefix--- $tablePrefix = !empty($connectionParams['tablePrefix']) ? $connectionParams['tablePrefix'] : null; if ($tablePrefix) { $evm = new EventManager(); $tablePrefix = new TablePrefix($tablePrefix); $evm->addEventListener(Events::loadClassMetadata, $tablePrefix); } //---/Table Prefix--- if ($smart) { self::$em = self::getEmSmart($path_to_entity, $isDev, $connectionParams, $evm); } else { if ($proxyPath === NULL) { $proxyPath = PATH_ROOT . '/' . Sokol::getApp()->name . '/Proxy'; } if ($proxyNamespace === NULL) { $proxyNamespace = Sokol::getApp()->getNamespace() . '\\Proxy'; } self::$em = self::getEm($path_to_entity, $isDev, $connectionParams, $evm, $proxyPath, $proxyNamespace); } //подключаем тип данных "html" Type::addType('html', 'Sokol\\Doctrine\\Extension\\HtmlType'); self::$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('db_html', 'html'); } return self::$em; }
public function boot() { if (false === Type::hasType(ExtendedDataType::NAME)) { ExtendedDataType::setEncryptionService($this->container->get('payment.encryption_service')); Type::addType(ExtendedDataType::NAME, 'JMS\\Payment\\CoreBundle\\Entity\\ExtendedDataType'); } }
protected function setUp() { $enumTypeClass = $this->getTypeClass(); if (!Type::hasType($this->getExpectedTypeName())) { Type::addType($this->getExpectedTypeName(), $enumTypeClass); } }
protected function setUp() { if (!Type::hasType('money')) { Type::addType('money', 'CSBill\\MoneyBundle\\Doctrine\\Types\\MoneyType'); MoneyType::setCurrency(new Currency('USD')); } }
function let() { if (!Type::hasType(GeographicLocationType::NAME)) { Type::addType(GeographicLocationType::NAME, 'DoctrineExt\\DBAL\\Types\\GeographicLocationType'); } $this->beConstructedThrough('getType', [GeographicLocationType::NAME]); }
protected function setUp() { parent::setUp(); DDC2494TinyIntType::$calls = array(); Type::addType('ddc2494_tinyint', __NAMESPACE__ . '\\DDC2494TinyIntType'); $this->_schemaTool->createSchema(array($this->_em->getClassMetadata(DDC2494Currency::CLASSNAME), $this->_em->getClassMetadata(DDC2494Campaign::CLASSNAME))); }
/** * Boots the bundle * * @return void */ public function boot() { if ($this->container->has('doctrine')) { Type::addType(MbStringType::TYPE_NAME, MbStringType::class); Type::addType(StdStringType::TYPE_NAME, StdStringType::class); Type::addType(DateTimeType::TYPE_NAME, DateTimeType::class); Type::addType(DateType::TYPE_NAME, DateType::class); Type::addType(TimeType::TYPE_NAME, TimeType::class); Type::addType(TimezoneType::TYPE_NAME, TimezoneType::class); Type::addType(UuidType::TYPE_NAME, UuidType::class); Type::addType(CurrencyType::TYPE_NAME, CurrencyType::class); Type::addType(MoneyType::TYPE_NAME, MoneyType::class); Type::addType(UriType::TYPE_NAME, UriType::class); Type::addType(UrlType::TYPE_NAME, UrlType::class); /** @var EntityManager $entityManager */ $entityManager = $this->container->get('doctrine')->getManager(); /** @var AbstractPlatform $platform */ $platform = $entityManager->getConnection()->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('db_' . MbStringType::TYPE_NAME, MbStringType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . StdStringType::TYPE_NAME, StdStringType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . DateTimeType::TYPE_NAME, DateTimeType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . DateType::TYPE_NAME, DateType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . TimeType::TYPE_NAME, TimeType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . TimezoneType::TYPE_NAME, TimezoneType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . UuidType::TYPE_NAME, UuidType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . CurrencyType::TYPE_NAME, CurrencyType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . MoneyType::TYPE_NAME, MoneyType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . UriType::TYPE_NAME, UriType::TYPE_NAME); $platform->registerDoctrineTypeMapping('db_' . UrlType::TYPE_NAME, UrlType::TYPE_NAME); } }
/** * @return Schema[] */ protected function prepareSchemas() { Type::addType('int', 'Doctrine\\DBAL\\Types\\IntegerType'); $fromSchema = new Schema(); $table = $fromSchema->createTable('oro_entity_extend_test_table'); $table->addColumn('id', 'integer', ['autoincrement' => true]); $table->addColumn('someExternalColumn', 'string'); $table->addColumn('relation_id', 'int'); $table->addIndex(['someExternalColumn'], 'some_external_index_name'); $table->setPrimaryKey(['id']); $tableRelation = $fromSchema->createTable('oro_entity_extend_test_relation'); $tableRelation->addColumn('id', 'integer', ['autoincrement' => true]); $tableRelation->addColumn('someExtendColumn', 'string'); $tableRelation->addIndex(['someExtendColumn'], 'oro_idx_index_name'); $tableRelation->setPrimaryKey(['id']); $table->addForeignKeyConstraint($tableRelation, ['relation_id'], ['id']); $toSchema = new Schema(); $table = $toSchema->createTable('oro_entity_extend_test_table'); $table->addColumn('id', 'integer', ['autoincrement' => true]); $table->setPrimaryKey(['id']); $tableRelation = $toSchema->createTable('oro_entity_extend_test_relation'); $tableRelation->addColumn('id', 'integer', ['autoincrement' => true]); $tableRelation->setPrimaryKey(['id']); return [$fromSchema, $toSchema]; }
public function __construct(DisconnectedClassMetadataFactory $cmf) { $this->cmf = $cmf; //allow sonata type 'json' if (!\Doctrine\DBAL\Types\Type::hasType('json')) { \Doctrine\DBAL\Types\Type::addType('json', 'Sonata\\Doctrine\\Types\\JsonType'); } }
protected function setUp() { $this->_platform = new MockPlatform(); if (!Type::hasType('vardatetime')) { Type::addType('vardatetime', 'Doctrine\\DBAL\\Types\\VarDateTimeType'); } $this->_type = Type::getType('vardatetime'); }
protected function setUp() { if (!Type::hasType($this->typeName)) { Type::addType($this->typeName, $this->typeClass); } $this->type = Type::getType($this->typeName); $this->platform = new PostgreSqlPlatform(); }
public function setUp() { if (Type::hasType('currency')) { Type::overrideType('currency', 'Sonata\\Component\\Currency\\CurrencyDoctrineType'); } else { Type::addType('currency', 'Sonata\\Component\\Currency\\CurrencyDoctrineType'); } }
/** * @param $name * @param $class * * @throws \Doctrine\DBAL\DBALException */ public function addType($name, $class) { if (!Type::hasType($name)) { Type::addType($name, $class); } else { Type::overrideType($name, $class); } }