Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 742b37e

Browse filesBrowse files
committed
Merge branch 'dql-functions' of git://github.com/stof/symfony-docs into stof-dql-functions
2 parents 69bd511 + 809bda9 commit 742b37e
Copy full SHA for 742b37e

File tree

Expand file treeCollapse file tree

3 files changed

+89
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+89
-2
lines changed

‎book/doctrine/dbal.rst

Copy file name to clipboardExpand all lines: book/doctrine/dbal.rst
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,38 @@ which is the first one defined or the one configured via the
132132
Each connection is also accessible via the ``doctrine.dbal.[name]_connection``
133133
service where ``[name]`` if the name of the connection.
134134

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+
135167
.. _PDO: http://www.php.net/pdo
136168
.. _documentation: http://www.doctrine-project.org/docs/dbal/2.0/en
137169
.. _Doctrine: http://www.doctrine-project.org

‎book/doctrine/orm.rst

Copy file name to clipboardExpand all lines: book/doctrine/orm.rst
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,50 @@ that use this connection.
460460
</services>
461461
</container>
462462
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+
463507
.. index::
464508
single: Doctrine; ORM Console Commands
465509
single: CLI; Doctrine ORM

‎reference/bundle_configuration/DoctrineBundle.rst

Copy file name to clipboardExpand all lines: reference/bundle_configuration/DoctrineBundle.rst
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ Configuration Reference
3838
auto_generate_proxy_classes: true
3939
proxy_namespace: Proxies
4040
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
4242
entity_managers:
43-
# At least one has to be defined
4443
default:
4544
# The name of a DBAL connection (the one marked as default is used if not set)
4645
connection: conn1
@@ -56,6 +55,13 @@ Configuration Reference
5655
port: 11211
5756
instance_class: Memcache
5857
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
5965
em2:
6066
# ...
6167
@@ -94,6 +100,11 @@ Configuration Reference
94100
<doctrine:entity-manager name="default" query-cache-driver="array" result-cache-driver="array" connection="conn1" class-metadata-factory-name="Doctrine\ORM\Mapping\ClassMetadataFactory">
95101
<doctrine:metadata-cache-driver type="memcache" host="localhost" port="11211" instance-class="Memcache" class="Doctrine\Common\Cache\MemcacheCache" />
96102
<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>
97108
</doctrine:entity-manager>
98109
<doctrine:entity-manager name="em2" connection="conn2" metadata-cache-driver="apc">
99110
<doctrine:mapping

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.