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

[phpcr-odm] change doc to best practices #807

Merged
merged 1 commit into from
Feb 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 50 additions & 50 deletions bundles/phpcr_odm/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ Configuration
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('doctrine_phpcr', array(
'session' => array(
'backend' => array(
$container->loadFromExtension('doctrine_phpcr', [
'session' => [
'backend' => [
'type' => 'X',
'parameters' => array(
'parameters' => [
'jackalope.factory' => 'Jackalope\Factory',
'jackalope.check_login_on_server' => false,
'jackalope.disable_stream_wrapper' => false,
'jackalope.auto_lastmodified' => true,
),
),
],
],
'workspace' => 'default',
'username' => 'admin',
'password' => 'admin',
'options' => array(
'options' => [
'jackalope.fetch_depth' => 1,
),
),
));
],
],
]);

``workspace``
"""""""""""""
Expand Down Expand Up @@ -233,18 +233,18 @@ PHPCR Session with Jackalope Jackrabbit
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('doctrine_phpcr', array(
'session' => array(
'backend' => array(
$container->loadFromExtension('doctrine_phpcr', [
'session' => [
'backend' => [
'type' => 'jackrabbit',
'url' => 'http://localhost:8080/server/',
'parameters' => array(
'parameters' => [
'jackalope.default_header' => 'X-ID: %serverid%',
'jackalope.jackrabbit_expect' => true,
),
),
),
));
],
],
],
]);

``url``
"""""""
Expand Down Expand Up @@ -327,24 +327,24 @@ supported by Doctrine.
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('doctrine_phpcr', array(
'session' => array(
'backend' => array(
$container->loadFromExtension('doctrine_phpcr', [
'session' => [
'backend' => [
'type' => 'doctrinedbal',
'connection' => 'default',
'caches' => array(
'caches' => [
'meta' => 'doctrine_cache.providers.phpcr_meta'
'nodes' => 'doctrine_cache.providers.phpcr_nodes'
),
'parameters' => array(
],
'parameters' => [
// ... general parameters and options

// optional parameters specific to Jackalope Doctrine Dbal
'jackalope.disable_transactions' => false,
),
),
),
));
],
],
],
]);

``connection``
""""""""""""""
Expand Down Expand Up @@ -408,15 +408,15 @@ debug toolbar:
.. code-block:: php

// app/config/config.yml
$container->loadFromExtension('doctrine_phpcr', array(
'session' => array(
'backend' => array(
$container->loadFromExtension('doctrine_phpcr', [
'session' => [
'backend' => [
// ...
'logging' => true,
'profiling' => true,
),
),
));
],
],
]);

Doctrine PHPCR-ODM Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -511,39 +511,39 @@ not configure anything here, the ODM services will not be loaded.
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('doctrine_phpcr', array(
'odm' => array(
$container->loadFromExtension('doctrine_phpcr', [
'odm' => [
'configuration_id' => null,
'auto_mapping' => true,
'auto_generate_proxy_classes' => '%kernel.debug%',
'proxy-dir' => '%kernel.cache_dir%/doctrine/PHPCRProxies',
'proxy_namespace' => 'PHPCRProxies',
'namespaces' => array(
'translation' => array(
'namespaces' => [
'translation' => [
'alias' => 'phpcr_locale',
),
),
'mappings' => array(
'<name>' => array(
],
],
'mappings' => [
'<name>' => [
'mapping' => true,
'type' => null,
'dir' => null,
'alias' => null,
'prefix' => null,
'is-bundle' => null,
),
),
'metadata_cache_driver' => array(
],
],
'metadata_cache_driver' => [
'type' => 'array',
'host' => null,
'port' => null,
'instance_class' => null,
'class' => null,
'id' => null,
'namespace' => null,
),
),
));
],
],
]);

``configuration_id``
""""""""""""""""""""
Expand Down Expand Up @@ -639,10 +639,10 @@ General Settings
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('doctrine_phpcr', array(
$container->loadFromExtension('doctrine_phpcr', [
'jackrabbit_jar' => '/path/to/jackrabbit.jar',
'dump_max_line_length' => 120,
));
]);

``jackrabbit_jar``
""""""""""""""""""
Expand Down
45 changes: 24 additions & 21 deletions bundles/phpcr_odm/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,61 +30,64 @@ use this configuration:

.. code-block:: yaml

# app/config/services.yml
services:
acme_search.listener.search:
class: Acme\SearchBundle\EventListener\SearchIndexer
app.phpcr_search_indexer:
class: AppBundle\EventListener\SearchIndexer
tags:
- { name: doctrine_phpcr.event_listener, event: postPersist }

acme_search.subscriber.fancy:
class: Acme\SearchBundle\EventSubscriber\MySubscriber
app.phpcr_listener:
class: AppBundle\EventListener\MyListener
tags:
- { name: doctrine_phpcr.event_subscriber }

.. code-block:: xml

<!-- src/Acme/SearchBundle/Resources/config/services.xml -->
<?xml version="1.0" ?>
<!-- app/config/config.xml -->
<container xmlns="http://symfony.com/schema/dic/services">
<services>
<service id="acme_search.listener.search"
class="Acme\SearchBundle\EventListener\SearchIndexer">
<service id="app.phpcr_search_indexer"
class="AppBundle\EventListener\SearchIndexer">
<tag name="doctrine_phpcr.event_listener" event="postPersist" />
</service>
<service id="acme_search.subscriber.fancy"
class="Acme\SearchBundle\EventSubscriber\MySubscriber">
<service id="app.phpcr_listener"
class="AppBundle\EventListener\MyListener">
<tag name="doctrine_phpcr.event_subscriber" />
</service>
</services>
</container>

.. code-block:: php

// app/config/config.php
use AppBundle\EventListener\SearchIndexer;
use AppBundle\EventListener\MyListener;

$container
->register(
'acme_search.listener.search',
'Acme\SearchBundle\EventListener\SearchIndexer'
'app.phpcr_search_indexer',
SearchIndexer::class
)
->addTag('doctrine_phpcr.event_listener', array(
->addTag('doctrine_phpcr.event_listener', [
'event' => 'postPersist',
))
])
;

$container
->register(
'acme_search.subscriber.fancy',
'Acme\SearchBundle\EventSubscriber\FancySubscriber'
'app.phpcr_listener',
MySubscriber::class
)
->addTag('doctrine_phpcr.event_subscriber', array(
'event' => 'postPersist',
))
->addTag('doctrine_phpcr.event_subscriber')
;

.. tip::

Doctrine event subscribers (both ORM and PHPCR-ODM) can not return a
flexible array of methods to call like the `Symfony event subscriber`_ can
do. Doctrine event subscribers must return a simple array of the event
Doctrine event subscribers (both ORM and PHPCR-ODM) can **not** return a
flexible array of methods to call like the `Symfony event subscriber`_.
Doctrine event subscribers must return a simple array of the event
names they subscribe to. Doctrine will then expect methods on the
subscriber with the names of the subscribed events, just as when using an
event listener.
Expand Down
Loading