Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 68f3271

Browse files
authored
Merge pull request #807 from symfony-cmf/bp-phpcr-odm
[phpcr-odm] change doc to best practices
2 parents 8586c0e + a9e6877 commit 68f3271

File tree

7 files changed

+262
-248
lines changed

7 files changed

+262
-248
lines changed

bundles/phpcr_odm/configuration.rst

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,25 @@ Configuration
6363
.. code-block:: php
6464
6565
// app/config/config.php
66-
$container->loadFromExtension('doctrine_phpcr', array(
67-
'session' => array(
68-
'backend' => array(
66+
$container->loadFromExtension('doctrine_phpcr', [
67+
'session' => [
68+
'backend' => [
6969
'type' => 'X',
70-
'parameters' => array(
70+
'parameters' => [
7171
'jackalope.factory' => 'Jackalope\Factory',
7272
'jackalope.check_login_on_server' => false,
7373
'jackalope.disable_stream_wrapper' => false,
7474
'jackalope.auto_lastmodified' => true,
75-
),
76-
),
75+
],
76+
],
7777
'workspace' => 'default',
7878
'username' => 'admin',
7979
'password' => 'admin',
80-
'options' => array(
80+
'options' => [
8181
'jackalope.fetch_depth' => 1,
82-
),
83-
),
84-
));
82+
],
83+
],
84+
]);
8585
8686
``workspace``
8787
"""""""""""""
@@ -233,18 +233,18 @@ PHPCR Session with Jackalope Jackrabbit
233233
.. code-block:: php
234234
235235
// app/config/config.php
236-
$container->loadFromExtension('doctrine_phpcr', array(
237-
'session' => array(
238-
'backend' => array(
236+
$container->loadFromExtension('doctrine_phpcr', [
237+
'session' => [
238+
'backend' => [
239239
'type' => 'jackrabbit',
240240
'url' => 'http://localhost:8080/server/',
241-
'parameters' => array(
241+
'parameters' => [
242242
'jackalope.default_header' => 'X-ID: %serverid%',
243243
'jackalope.jackrabbit_expect' => true,
244-
),
245-
),
246-
),
247-
));
244+
],
245+
],
246+
],
247+
]);
248248
249249
``url``
250250
"""""""
@@ -327,24 +327,24 @@ supported by Doctrine.
327327
.. code-block:: php
328328
329329
// app/config/config.php
330-
$container->loadFromExtension('doctrine_phpcr', array(
331-
'session' => array(
332-
'backend' => array(
330+
$container->loadFromExtension('doctrine_phpcr', [
331+
'session' => [
332+
'backend' => [
333333
'type' => 'doctrinedbal',
334334
'connection' => 'default',
335-
'caches' => array(
335+
'caches' => [
336336
'meta' => 'doctrine_cache.providers.phpcr_meta'
337337
'nodes' => 'doctrine_cache.providers.phpcr_nodes'
338-
),
339-
'parameters' => array(
338+
],
339+
'parameters' => [
340340
// ... general parameters and options
341341
342342
// optional parameters specific to Jackalope Doctrine Dbal
343343
'jackalope.disable_transactions' => false,
344-
),
345-
),
346-
),
347-
));
344+
],
345+
],
346+
],
347+
]);
348348
349349
``connection``
350350
""""""""""""""
@@ -408,15 +408,15 @@ debug toolbar:
408408
.. code-block:: php
409409
410410
// app/config/config.yml
411-
$container->loadFromExtension('doctrine_phpcr', array(
412-
'session' => array(
413-
'backend' => array(
411+
$container->loadFromExtension('doctrine_phpcr', [
412+
'session' => [
413+
'backend' => [
414414
// ...
415415
'logging' => true,
416416
'profiling' => true,
417-
),
418-
),
419-
));
417+
],
418+
],
419+
]);
420420
421421
Doctrine PHPCR-ODM Configuration
422422
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -511,39 +511,39 @@ not configure anything here, the ODM services will not be loaded.
511511
.. code-block:: php
512512
513513
// app/config/config.php
514-
$container->loadFromExtension('doctrine_phpcr', array(
515-
'odm' => array(
514+
$container->loadFromExtension('doctrine_phpcr', [
515+
'odm' => [
516516
'configuration_id' => null,
517517
'auto_mapping' => true,
518518
'auto_generate_proxy_classes' => '%kernel.debug%',
519519
'proxy-dir' => '%kernel.cache_dir%/doctrine/PHPCRProxies',
520520
'proxy_namespace' => 'PHPCRProxies',
521-
'namespaces' => array(
522-
'translation' => array(
521+
'namespaces' => [
522+
'translation' => [
523523
'alias' => 'phpcr_locale',
524-
),
525-
),
526-
'mappings' => array(
527-
'<name>' => array(
524+
],
525+
],
526+
'mappings' => [
527+
'<name>' => [
528528
'mapping' => true,
529529
'type' => null,
530530
'dir' => null,
531531
'alias' => null,
532532
'prefix' => null,
533533
'is-bundle' => null,
534-
),
535-
),
536-
'metadata_cache_driver' => array(
534+
],
535+
],
536+
'metadata_cache_driver' => [
537537
'type' => 'array',
538538
'host' => null,
539539
'port' => null,
540540
'instance_class' => null,
541541
'class' => null,
542542
'id' => null,
543543
'namespace' => null,
544-
),
545-
),
546-
));
544+
],
545+
],
546+
]);
547547
548548
``configuration_id``
549549
""""""""""""""""""""
@@ -639,10 +639,10 @@ General Settings
639639
.. code-block:: php
640640
641641
// app/config/config.php
642-
$container->loadFromExtension('doctrine_phpcr', array(
642+
$container->loadFromExtension('doctrine_phpcr', [
643643
'jackrabbit_jar' => '/path/to/jackrabbit.jar',
644644
'dump_max_line_length' => 120,
645-
));
645+
]);
646646
647647
``jackrabbit_jar``
648648
""""""""""""""""""

bundles/phpcr_odm/events.rst

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,61 +30,64 @@ use this configuration:
3030

3131
.. code-block:: yaml
3232
33+
# app/config/services.yml
3334
services:
34-
acme_search.listener.search:
35-
class: Acme\SearchBundle\EventListener\SearchIndexer
35+
app.phpcr_search_indexer:
36+
class: AppBundle\EventListener\SearchIndexer
3637
tags:
3738
- { name: doctrine_phpcr.event_listener, event: postPersist }
3839
39-
acme_search.subscriber.fancy:
40-
class: Acme\SearchBundle\EventSubscriber\MySubscriber
40+
app.phpcr_listener:
41+
class: AppBundle\EventListener\MyListener
4142
tags:
4243
- { name: doctrine_phpcr.event_subscriber }
4344
4445
.. code-block:: xml
4546
46-
<!-- src/Acme/SearchBundle/Resources/config/services.xml -->
4747
<?xml version="1.0" ?>
48+
<!-- app/config/config.xml -->
4849
<container xmlns="http://symfony.com/schema/dic/services">
4950
<services>
50-
<service id="acme_search.listener.search"
51-
class="Acme\SearchBundle\EventListener\SearchIndexer">
51+
<service id="app.phpcr_search_indexer"
52+
class="AppBundle\EventListener\SearchIndexer">
5253
<tag name="doctrine_phpcr.event_listener" event="postPersist" />
5354
</service>
54-
<service id="acme_search.subscriber.fancy"
55-
class="Acme\SearchBundle\EventSubscriber\MySubscriber">
55+
<service id="app.phpcr_listener"
56+
class="AppBundle\EventListener\MyListener">
5657
<tag name="doctrine_phpcr.event_subscriber" />
5758
</service>
5859
</services>
5960
</container>
6061
6162
.. code-block:: php
6263
64+
// app/config/config.php
65+
use AppBundle\EventListener\SearchIndexer;
66+
use AppBundle\EventListener\MyListener;
67+
6368
$container
6469
->register(
65-
'acme_search.listener.search',
66-
'Acme\SearchBundle\EventListener\SearchIndexer'
70+
'app.phpcr_search_indexer',
71+
SearchIndexer::class
6772
)
68-
->addTag('doctrine_phpcr.event_listener', array(
73+
->addTag('doctrine_phpcr.event_listener', [
6974
'event' => 'postPersist',
70-
))
75+
])
7176
;
7277
7378
$container
7479
->register(
75-
'acme_search.subscriber.fancy',
76-
'Acme\SearchBundle\EventSubscriber\FancySubscriber'
80+
'app.phpcr_listener',
81+
MySubscriber::class
7782
)
78-
->addTag('doctrine_phpcr.event_subscriber', array(
79-
'event' => 'postPersist',
80-
))
83+
->addTag('doctrine_phpcr.event_subscriber')
8184
;
8285
8386
.. tip::
8487

85-
Doctrine event subscribers (both ORM and PHPCR-ODM) can not return a
86-
flexible array of methods to call like the `Symfony event subscriber`_ can
87-
do. Doctrine event subscribers must return a simple array of the event
88+
Doctrine event subscribers (both ORM and PHPCR-ODM) can **not** return a
89+
flexible array of methods to call like the `Symfony event subscriber`_.
90+
Doctrine event subscribers must return a simple array of the event
8891
names they subscribe to. Doctrine will then expect methods on the
8992
subscriber with the names of the subscribed events, just as when using an
9093
event listener.

0 commit comments

Comments
 (0)