@@ -75,17 +75,68 @@ In Symfony, you can register your custom DQL functions as follows:
75
75
orm directly will trigger the exception `Unrecognized option "dql" under "doctrine.orm" `.
76
76
The `dql ` configuration block must be defined under the named entity manager.
77
77
78
- .. code-block :: yaml
79
-
80
- # app/config/config.yml
81
- doctrine :
82
- orm :
83
- # ...
84
- entity_managers :
85
- example_manager :
86
- # Place your functions here
87
- dql :
88
- datetime_functions :
89
- test_datetime : AppBundle\DQL\DatetimeFunction
78
+ .. configuration-block ::
79
+
80
+ .. code-block :: yaml
81
+
82
+ # app/config/config.yml
83
+ doctrine:
84
+ orm:
85
+ # ...
86
+ entity_managers:
87
+ example_manager:
88
+ # Place your functions here
89
+ dql:
90
+ datetime_functions:
91
+ test_datetime: AppBundle\DQL\DatetimeFunction
92
+
93
+ .. code-block :: xml
94
+
95
+ # app/config/config.xml
96
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
97
+ <container xmlns =" http://symfony.com/schema/dic/services"
98
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
99
+ xmlns : doctrine =" http://symfony.com/schema/dic/doctrine"
100
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
101
+ http://symfony.com/schema/dic/services/services-1.0.xsd
102
+ http://symfony.com/schema/dic/doctrine
103
+ http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd" >
104
+
105
+ <doctrine : config >
106
+ <doctrine : orm >
107
+ <!-- ... -->
108
+
109
+ <doctrine : entity-manager name =" example_manager" >
110
+ <!-- place your functions here -->
111
+ <doctrine : dql >
112
+ <doctrine : datetime-function name =" test_datetime" >
113
+ AppBundle\DQL\DatetimeFunction
114
+ </doctrine : datetime-function >
115
+ </doctrine : dql >
116
+ </doctrine : entity-manager >
117
+ </doctrine : orm >
118
+ </doctrine : config >
119
+ </container >
120
+
121
+ .. code-block :: php
122
+
123
+ // app/config/config.php
124
+ $container->loadFromExtension('doctrine', array(
125
+ 'doctrine' => array(
126
+ 'orm' => array(
127
+ // ...
128
+ 'entity_managers' => array(
129
+ 'example_manager' => array(
130
+ // place your functions here
131
+ 'dql' => array(
132
+ 'datetime_functions' => array(
133
+ 'test_datetime' => 'AppBundle\DQL\DatetimeFunction',
134
+ ),
135
+ ),
136
+ ),
137
+ ),
138
+ ),
139
+ ),
140
+ ));
90
141
91
142
.. _`DQL User Defined Functions` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/dql-user-defined-functions.html
0 commit comments