本文整理汇总了PHP中Doctrine\DBAL\Types\Type::overrideType方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::overrideType方法的具体用法?PHP Type::overrideType怎么用?PHP Type::overrideType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Types\Type
的用法示例。
在下文中一共展示了Type::overrideType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceImmutableTypes
/**
* Replaces default DateTime Doctrine types with their _immutable counterparts
*/
public static function replaceImmutableTypes()
{
Type::overrideType(Type::DATE, DateTimeImmutable\DateImmutableType::class);
Type::overrideType(Type::DATETIME, DateTimeImmutable\DateTimeImmutableType::class);
Type::overrideType(Type::DATETIMETZ, DateTimeImmutable\DateTimeTzImmutableType::class);
Type::overrideType(Type::TIME, DateTimeImmutable\TimeImmutableType::class);
}
示例2: __construct
/**
* @param array $options
* @param \Zend_Cache_Core $cache
* @param \Enlight_Hook_HookManager $hookManager
*/
public function __construct($options, \Zend_Cache_Core $cache, \Enlight_Hook_HookManager $hookManager)
{
$this->setHookManager($hookManager);
// Specifies the FQCN of a subclass of the EntityRepository.
// That will be available for all entities without a custom repository class.
$this->setDefaultRepositoryClassName('Shopware\\Components\\Model\\ModelRepository');
$this->setProxyDir($options['proxyDir']);
$this->setProxyNamespace($options['proxyNamespace']);
$this->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS);
$this->setAttributeDir($options['attributeDir']);
$this->setFileCacheDir($options['fileCacheDir']);
$this->addEntityNamespace('Shopware', 'Shopware\\Models');
$this->addEntityNamespace('Custom', 'Shopware\\CustomModels');
Type::overrideType('datetime', 'Shopware\\Components\\Model\\DBAL\\Types\\DateTimeStringType');
Type::overrideType('date', 'Shopware\\Components\\Model\\DBAL\\Types\\DateStringType');
Type::overrideType('array', 'Shopware\\Components\\Model\\DBAL\\Types\\AllowInvalidArrayType');
$this->addCustomStringFunction('DATE_FORMAT', 'Shopware\\Components\\Model\\Query\\Mysql\\DateFormat');
$this->addCustomStringFunction('IFNULL', 'Shopware\\Components\\Model\\Query\\Mysql\\IfNull');
$this->addCustomStringFunction('RegExp', 'Shopware\\Components\\Model\\Query\\Mysql\\RegExp');
$this->addCustomStringFunction('Replace', 'Shopware\\Components\\Model\\Query\\Mysql\\Replace');
// Load custom namespace for doctrine cache provider, if provided
if (isset($options['cacheNamespace'])) {
$this->cacheNamespace = $options['cacheNamespace'];
}
if (isset($options['cacheProvider'])) {
$this->setCacheProvider($options['cacheProvider']);
}
if ($this->getMetadataCacheImpl() === null) {
$this->setCacheResource($cache);
}
}
示例3: setUp
protected function setUp()
{
if (Type::hasType(ExtendedDataType::NAME)) {
Type::overrideType(ExtendedDataType::NAME, 'JMS\\Payment\\CoreBundle\\Entity\\ExtendedDataType');
} else {
Type::addType(ExtendedDataType::NAME, 'JMS\\Payment\\CoreBundle\\Entity\\ExtendedDataType');
}
}
示例4: setUp
public function setUp()
{
if (Type::hasType('json')) {
Type::overrideType('json', 'Sonata\\Doctrine\\Types\\JsonType');
} else {
Type::addType('json', 'Sonata\\Doctrine\\Types\\JsonType');
}
}
示例5: addType
/**
* @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);
}
}
示例6: setUp
protected function setUp()
{
if (DBALType::hasType('negative_to_positive')) {
DBALType::overrideType('negative_to_positive', 'Doctrine\\Tests\\DbalTypes\\NegativeToPositiveType');
} else {
DBALType::addType('negative_to_positive', 'Doctrine\\Tests\\DbalTypes\\NegativeToPositiveType');
}
$this->_em = $this->_getTestEntityManager();
}
示例7: setUpDBALTypes
/**
* Configures DBAL types required in tests
*/
protected function setUpDBALTypes()
{
if (Type::hasType('jsonb')) {
Type::overrideType('jsonb', 'Boldtrn\\JsonbBundle\\Types\\JsonbArrayType');
} else {
Type::addType('jsonb', 'Boldtrn\\JsonbBundle\\Types\\JsonbArrayType');
}
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('JSONB', 'jsonb');
}
示例8: setUp
protected function setUp()
{
$this->generator = \Mockery::mock(EnumTypeGenerator::class);
$this->storage = \Mockery::mock(EnumTypeStorage::class);
$this->sut = new EnumTypeRegistry($this->generator, $this->storage);
if (Type::hasType('foobar')) {
Type::overrideType('foobar', null);
}
}
示例9: boot
public function boot()
{
// Register custom data types
if (!Type::hasType('uniqueidentifier')) {
Type::addType('uniqueidentifier', 'Realestate\\MssqlBundle\\Types\\UniqueidentifierType');
}
Type::overrideType('date', 'Realestate\\MssqlBundle\\Types\\DateType');
Type::overrideType('datetime', 'Realestate\\MssqlBundle\\Types\\DateTimeType');
}
示例10: initializeTypes
private function initializeTypes()
{
foreach ($this->typesConfig as $type => $className) {
if (Type::hasType($type)) {
Type::overrideType($type, $className);
} else {
Type::addType($type, $className);
}
}
}
示例11: setUp
protected function setUp()
{
if (DBALType::hasType(CustomIdObjectType::NAME)) {
DBALType::overrideType(CustomIdObjectType::NAME, CustomIdObjectType::CLASSNAME);
} else {
DBALType::addType(CustomIdObjectType::NAME, CustomIdObjectType::CLASSNAME);
}
$this->useModelSet('custom_id_object_type');
parent::setUp();
}
示例12: setUp
public function setUp()
{
// Type is a singleton.
if (Type::hasType(self::TYPE_NAME)) {
// Remove the type so it can be re-instantiated.
Type::overrideType(self::TYPE_NAME, null);
}
Type::addType(self::TYPE_NAME, 'Omeka\\Db\\Type\\IpAddress');
$this->ipAddress = Type::getType(self::TYPE_NAME);
$this->platform = $this->getMockForAbstractClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
}
示例13: __construct
/**
* {@inheritDoc}
*/
public function __construct()
{
parent::__construct();
$this->initializeDoctrineTypeMappings();
if (!Type::hasType(MapType::NAME)) {
Type::addType(MapType::NAME, 'Crate\\DBAL\\Types\\MapType');
}
if (!Type::hasType(TimestampType::NAME)) {
Type::addType(TimestampType::NAME, 'Crate\\DBAL\\Types\\TimestampType');
}
Type::overrideType('array', 'Crate\\DBAL\\Types\\ArrayType');
}
示例14: testSerialization
public function testSerialization()
{
$array = array('a' => 'b');
$encoded = base64_encode(serialize($array));
$platform = TestUtil::getEntityManager()->getConnection()->getDatabasePlatform();
Type::overrideType(Type::TARRAY, 'Oro\\DBAL\\Types\\ArrayType');
$type = Type::getType(Type::TARRAY);
$actualDbValue = $type->convertToDatabaseValue($array, $platform);
$this->assertEquals($encoded, $actualDbValue);
$this->assertEquals($array, $type->convertToPHPValue($actualDbValue, $platform));
$this->assertEquals($array, $type->convertToPHPValue($encoded, $platform));
}
示例15: initializeTypes
/**
* initialize the types
*/
private function initializeTypes()
{
foreach ($this->typesConfig as $type => $typeConfig) {
if (Type::hasType($type)) {
Type::overrideType($type, $typeConfig['class']);
} else {
Type::addType($type, $typeConfig['class']);
}
if ($typeConfig['commented']) {
$this->commentedTypes[] = $type;
}
}
}