Skip to content

Commit d6ee23d

Browse files
committed
[book][doctrine] A few small tweaks - also trying to add some PHP config
1 parent 742b37e commit d6ee23d

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

book/doctrine/dbal.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,17 @@ 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
135+
Registering Custom Mapping Types
136136
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137137

138-
You can register custom types through the configuration. They will be added to
139-
all configured connections.
138+
You can register custom mapping types through the configuration. They will
139+
be added to all configured connections.
140140

141141
.. configuration-block::
142142

143143
.. code-block:: yaml
144144
145+
# app/config/config.yml
145146
doctrine:
146147
dbal:
147148
types:
@@ -150,6 +151,7 @@ all configured connections.
150151
151152
.. code-block:: xml
152153
154+
<!-- app/config/config.xml -->
153155
<container xmlns="http://symfony.com/schema/dic/services"
154156
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
155157
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
@@ -164,6 +166,18 @@ all configured connections.
164166
</doctrine:config>
165167
</container>
166168
169+
.. code-block:: php
170+
171+
// app/config/config.php
172+
$container->loadFromExtension('doctrine', array(
173+
'dbal' => array(
174+
'types' => array(
175+
'custom_first' => 'Acme\HelloBundle\Type\CustomFirst',
176+
'custom_second' => 'Acme\HelloBundle\Type\CustomSecond',
177+
),
178+
),
179+
));
180+
167181
.. _PDO: http://www.php.net/pdo
168182
.. _documentation: http://www.doctrine-project.org/docs/dbal/2.0/en
169183
.. _Doctrine: http://www.doctrine-project.org

book/doctrine/orm.rst

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,22 @@ that use this connection.
460460
</services>
461461
</container>
462462
463-
Registering custom DQL functions
463+
Registering Custom DQL Functions
464464
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465465

466-
You can register custom DQL functions throught the configuration.
466+
You can register custom DQL functions through the configuration.
467467

468468
.. configuration-block::
469469

470470
.. code-block:: yaml
471471
472+
# app/config/config.yml
472473
doctrine:
473474
orm:
475+
# ...
474476
entity_managers:
475477
default:
478+
# ...
476479
dql:
477480
string_functions:
478481
test_string: Acme\HelloBundle\DQL\StringFunction
@@ -484,6 +487,7 @@ You can register custom DQL functions throught the configuration.
484487
485488
.. code-block:: xml
486489
490+
<!-- app/config/config.xml -->
487491
<container xmlns="http://symfony.com/schema/dic/services"
488492
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
489493
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
@@ -492,7 +496,9 @@ You can register custom DQL functions throught the configuration.
492496
493497
<doctrine:config>
494498
<doctrine:orm>
499+
<!-- ... -->
495500
<doctrine:entity-manager name="default">
501+
<!-- ... -->
496502
<doctrine:dql>
497503
<doctrine:string-function name="test_string>Acme\HelloBundle\DQL\StringFunction</doctrine:string-function>
498504
<doctrine:string-function name="second_string>Acme\HelloBundle\DQL\SecondStringFunction</doctrine:string-function>
@@ -504,6 +510,32 @@ You can register custom DQL functions throught the configuration.
504510
</doctrine:config>
505511
</container>
506512
513+
.. code-block:: php
514+
515+
// app/config/config.php
516+
$container->loadFromExtension('doctrine', array(
517+
'orm' => array(
518+
// ...
519+
'entity_managers' => array(
520+
'default' => array(
521+
// ...
522+
'dql' => array(
523+
'string_functions' => array(
524+
'test_string' => 'Acme\HelloBundle\DQL\StringFunction',
525+
'second_string' => 'Acme\HelloBundle\DQL\SecondStringFunction',
526+
),
527+
'numeric_functions' => array(
528+
'test_numeric' => 'Acme\HelloBundle\DQL\NumericFunction',
529+
),
530+
'datetime_functions' => array(
531+
'test_datetime' => 'Acme\HelloBundle\DQL\DatetimeFunction',
532+
),
533+
),
534+
),
535+
),
536+
),
537+
));
538+
507539
.. index::
508540
single: Doctrine; ORM Console Commands
509541
single: CLI; Doctrine ORM

0 commit comments

Comments
 (0)