本文整理匯總了PHP中Doctrine\DBAL\Types\Type::addType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Type::addType方法的具體用法?PHP Type::addType怎麽用?PHP Type::addType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\DBAL\Types\Type
的用法示例。
在下文中一共展示了Type::addType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
if (!Type::hasType('point')) {
Type::addType('point', 'Doctrine\\Tests\\Types\\MySqlPointType');
}
}
示例2: setUpBeforeClass
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');
}
示例3: loadClassMetadata
/**
* 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]);
}
}
示例4: setUp
protected function setUp()
{
if (!Type::hasType(PercentType::TYPE)) {
Type::addType(PercentType::TYPE, 'Oro\\DBAL\\Types\\PercentType');
}
$this->percentType = Type::getType(PercentType::TYPE);
}
示例5: boot
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');
}
}
示例6: __construct
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');
}
示例7: setUp
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);
}
示例8: buildEntityManagers
/**
* @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()]);
}
}
示例9: doctrineInit
function doctrineInit($cachedAnnotationReader)
{
$evm = new Doctrine\Common\EventManager();
bootstrapAddTreeExtension($evm, $cachedAnnotationReader);
Type::addType('mediainfotype', 'Uppu4\\Type\\MediaInfoType');
return $evm;
}
示例10: boot
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 :-)
}
}
示例11: onBootstrap
/**
* @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));
}
示例12: setUp
public function setUp()
{
if (!Type::hasType('point')) {
Type::addType('point', 'CrEOF\\Spatial\\DBAL\\Types\\Geometry\\PointType');
}
parent::setUp();
}
示例13: boot
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');
}
示例14: __construct
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');
}
}
示例15: setUp
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')));
}