Skip to content

Commit 42115ab

Browse files
committed
Adding support for custom types
1 parent 529f5f2 commit 42115ab

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ Configuration
230230
String or array describing metadata cache implementation.
231231
* **result_cache** (Default: setting specified by orm.default_cache):
232232
String or array describing result cache implementation.
233+
* **types**
234+
An array of custom types in the format of 'typeName' => 'Namespace\To\Type\Class'
233235
* **orm.ems.options**:
234236
Array of Entity Manager configuration sets indexed by each Entity Manager's
235237
name. Each value should look like **orm.em.options**.

src/Dflydev/Pimple/Provider/DoctrineOrm/DoctrineOrmServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Doctrine\Common\Cache\RedisCache;
2222
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
2323
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
24+
use Doctrine\DBAL\Types\Type;
2425
use Doctrine\ORM\Configuration;
2526
use Doctrine\ORM\EntityManager;
2627
use Doctrine\ORM\Mapping\Driver\Driver;
@@ -163,6 +164,14 @@ public function register(\Pimple $app)
163164
}
164165
$config->setMetadataDriverImpl($chain);
165166

167+
foreach ((array) $options['types'] as $typeName => $typeClass) {
168+
if (Type::hasType($typeName)) {
169+
Type::overrideType($typeName, $typeClass);
170+
} else {
171+
Type::addType($typeName, $typeClass);
172+
}
173+
}
174+
166175
$configs[$name] = $config;
167176
}
168177

0 commit comments

Comments
 (0)