File tree Expand file tree Collapse file tree 3 files changed +89
-2
lines changed
Filter options
reference/bundle_configuration Expand file tree Collapse file tree 3 files changed +89
-2
lines changed
Original file line number Diff line number Diff line change @@ -132,6 +132,38 @@ which is the first one defined or the one configured via the
132
132
Each connection is also accessible via the ``doctrine.dbal.[name]_connection ``
133
133
service where ``[name] `` if the name of the connection.
134
134
135
+ Registering custom Mapping Types
136
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137
+
138
+ You can register custom types through the configuration. They will be added to
139
+ all configured connections.
140
+
141
+ .. configuration-block ::
142
+
143
+ .. code-block :: yaml
144
+
145
+ doctrine :
146
+ dbal :
147
+ types :
148
+ custom_first : Acme\HelloBundle\Type\CustomFirst
149
+ custom_second : Acme\HelloBundle\Type\CustomSecond
150
+
151
+ .. code-block :: xml
152
+
153
+ <container xmlns =" http://symfony.com/schema/dic/services"
154
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
155
+ xmlns : doctrine =" http://symfony.com/schema/dic/doctrine"
156
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
157
+ http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd" >
158
+
159
+ <doctrine : config >
160
+ <doctrine : dbal >
161
+ <doctrine : type name =" custom_first" class =" Acme\HelloBundle\Type\CustomFirst" />
162
+ <doctrine : type name =" custom_second" class =" Acme\HelloBundle\Type\CustomSecond" />
163
+ </doctrine : dbal >
164
+ </doctrine : config >
165
+ </container >
166
+
135
167
.. _PDO : http://www.php.net/pdo
136
168
.. _documentation : http://www.doctrine-project.org/docs/dbal/2.0/en
137
169
.. _Doctrine : http://www.doctrine-project.org
Original file line number Diff line number Diff line change @@ -460,6 +460,50 @@ that use this connection.
460
460
</services >
461
461
</container >
462
462
463
+ Registering custom DQL functions
464
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465
+
466
+ You can register custom DQL functions throught the configuration.
467
+
468
+ .. configuration-block ::
469
+
470
+ .. code-block :: yaml
471
+
472
+ doctrine :
473
+ orm :
474
+ entity_managers :
475
+ default :
476
+ dql :
477
+ string_functions :
478
+ test_string : Acme\HelloBundle\DQL\StringFunction
479
+ second_string : Acme\HelloBundle\DQL\SecondStringFunction
480
+ numeric_functions :
481
+ test_numeric : Acme\HelloBundle\DQL\NumericFunction
482
+ datetime_functions :
483
+ test_datetime : Acme\HelloBundle\DQL\DatetimeFunction
484
+
485
+ .. code-block :: xml
486
+
487
+ <container xmlns =" http://symfony.com/schema/dic/services"
488
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
489
+ xmlns : doctrine =" http://symfony.com/schema/dic/doctrine"
490
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
491
+ http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd" >
492
+
493
+ <doctrine : config >
494
+ <doctrine : orm >
495
+ <doctrine : entity-manager name =" default" >
496
+ <doctrine : dql >
497
+ <doctrine : string-function name =" test_string>Acme\HelloBundle\DQL\StringFunction</doctrine:string-function>
498
+ <doctrine:string-function name=" second_string>Acme\HelloBundle\DQL\SecondStringFunction</doctrine : string-function >
499
+ <doctrine : numeric-function name =" test_numeric>Acme\HelloBundle\DQL\NumericFunction</doctrine:numeric-function>
500
+ <doctrine:datetime-function name=" test_datetime>Acme\HelloBundle\DQL\DatetimeFunction</doctrine : datetime-function >
501
+ </doctrine : dql >
502
+ </doctrine : entity-manager >
503
+ </doctrine : orm >
504
+ </doctrine : config >
505
+ </container >
506
+
463
507
.. index ::
464
508
single: Doctrine; ORM Console Commands
465
509
single: CLI; Doctrine ORM
Original file line number Diff line number Diff line change @@ -38,9 +38,8 @@ Configuration Reference
38
38
auto_generate_proxy_classes : true
39
39
proxy_namespace : Proxies
40
40
proxy_dir : %kernel.cache_dir%/doctrine/orm/Proxies
41
- default_entity_manager : default # Required
41
+ default_entity_manager : default # The first defined is used if not set
42
42
entity_managers :
43
- # At least one has to be defined
44
43
default :
45
44
# The name of a DBAL connection (the one marked as default is used if not set)
46
45
connection : conn1
@@ -56,6 +55,13 @@ Configuration Reference
56
55
port : 11211
57
56
instance_class : Memcache
58
57
class : Doctrine\Common\Cache\MemcacheCache
58
+ dql :
59
+ string_functions :
60
+ test_string : Acme\HelloBundle\DQL\StringFunction
61
+ numeric_functions :
62
+ test_numeric : Acme\HelloBundle\DQL\NumericFunction
63
+ datetime_functions :
64
+ test_datetime : Acme\HelloBundle\DQL\DatetimeFunction
59
65
em2 :
60
66
# ...
61
67
@@ -94,6 +100,11 @@ Configuration Reference
94
100
<doctrine : entity-manager name =" default" query-cache-driver =" array" result-cache-driver =" array" connection =" conn1" class-metadata-factory-name =" Doctrine\ORM\Mapping\ClassMetadataFactory" >
95
101
<doctrine : metadata-cache-driver type =" memcache" host =" localhost" port =" 11211" instance-class =" Memcache" class =" Doctrine\Common\Cache\MemcacheCache" />
96
102
<doctrine : mapping name =" AcmeHelloBundle" />
103
+ <doctrine : dql >
104
+ <doctrine : string-function name =" test_string>Acme\HelloBundle\DQL\StringFunction</doctrine:string-function>
105
+ <doctrine:numeric-function name=" test_numeric>Acme\HelloBundle\DQL\NumericFunction</doctrine : numeric-function >
106
+ <doctrine : datetime-function name =" test_datetime>Acme\HelloBundle\DQL\DatetimeFunction</doctrine:datetime-function>
107
+ </doctrine:dql>
97
108
</doctrine:entity-manager>
98
109
<doctrine:entity-manager name=" em2" connection=" conn2" metadata-cache-driver=" apc" >
99
110
<doctrine:mapping
You can’t perform that action at this time.
0 commit comments