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

Commit 427a874

Browse files
committed
Merge pull request #640 from jonathonwalz/create-bundle-chain-mapper
[WCM] Add CreateBundle chain mapper information
2 parents 225f9ab + 08e030b commit 427a874

File tree

2 files changed

+119
-26
lines changed

2 files changed

+119
-26
lines changed

bundles/create/configuration.rst

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,35 @@ For more information, see the
6262
),
6363
));
6464
65+
.. _config-create-object-mapper-service-id:
66+
67+
``object_mapper_service_id``
68+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69+
70+
**type**: ``string`` **default**: ``"cmf_create.chain_mapper"``
71+
72+
You can specify a service implementing ``Midgard\CreatePHP\RdfMapperInterface``
73+
that will handle objects that need to be stored by the REST handler of
74+
CreatePHP. You need to either specify this service, enable phpcr or orm
75+
persistence or define one or more services that implement the
76+
``Midgard\CreatePHP\RdfChainableMapperInterface`` and tag them with ``cmf_create.mapper``.
77+
6578
.. _config-create-persistence:
6679

6780
``persistence``
6881
~~~~~~~~~~~~~~~
6982

70-
This defines the persistence driver and associated classes. The default
71-
persistence configuration has the following configuration:
83+
This defines a persistence driver for Doctrine PHPCR-ODM documents or Doctrine ORM entities.
84+
If you specify neither, see :ref:`config-create-object-mapper-service-id`.
85+
86+
``phpcr``
87+
.........
7288

7389
.. configuration-block::
7490

7591
.. code-block:: yaml
7692
7793
cmf_create:
78-
object_mapper_service_id: ~
7994
persistence:
8095
phpcr:
8196
enabled: false
@@ -127,13 +142,6 @@ persistence configuration has the following configuration:
127142
),
128143
));
129144
130-
``object_mapper_service_id``
131-
""""""""""""""""""""""""""""
132-
133-
You can specify a service implementing ``Midgard\CreatePHP\RdfMapperInterface``
134-
that will handle objects that need to be stored by the REST handler of
135-
CreatePHP. You need to either specify this service or enable the phpcr
136-
persistence for this bundle to work.
137145
138146
``enabled``
139147
"""""""""""
@@ -164,6 +172,60 @@ Set delete to true to enable the simple delete workflow. This allows to directly
164172
delete content from the frontend. Be careful, there are no special checks once you confirm deletion
165173
your content is gone.
166174

175+
``orm``
176+
.......
177+
178+
.. configuration-block::
179+
180+
.. code-block:: yaml
181+
182+
cmf_create:
183+
persistence:
184+
orm:
185+
enabled: false
186+
manager_name: ~
187+
188+
.. code-block:: xml
189+
190+
<?xml version="1.0" charset="UTF-8" ?>
191+
<container xmlns="http://symfony.com/schema/dic/services">
192+
<config xmlns="http://cmf.symfony.com/schema/dic/create">
193+
<persistence>
194+
<orm
195+
enabled="false"
196+
manager-name="null"
197+
/>
198+
</persistence>
199+
</config>
200+
</container>
201+
202+
.. code-block:: php
203+
204+
$container->loadFromExtension('cmf_create', array(
205+
'persistence' => array(
206+
'orm' => array(
207+
'enabled' => false,
208+
'manager_name' => null,
209+
),
210+
),
211+
));
212+
213+
214+
``enabled``
215+
"""""""""""
216+
217+
**type**: ``boolean`` **default**: ``false``
218+
219+
If ``true``, the ORM is included in the chain mapper.
220+
221+
``manager_name``
222+
""""""""""""""""
223+
224+
**type**: ``string`` **default**: ``null``
225+
226+
The name of the Doctrine Manager to use.
227+
228+
167229
Metadata Handling
168230
~~~~~~~~~~~~~~~~~
169231

@@ -198,19 +260,19 @@ Metadata Handling
198260
));
199261
200262
``auto_mapping``
201-
""""""""""""""""
263+
................
202264

203265
If not set to false, the CreateBundle will look for mapping files in every
204266
bundle in the directory ``Resources/rdf-mappings``.
205267

206268
``rdf_config_dirs``
207-
"""""""""""""""""""
269+
...................
208270

209271
Additional directories to look for mapping files besides the auto mapped
210272
directory.
211273

212274
``map``
213-
"""""""
275+
.......
214276

215277
Mapping from RDF type name to class. This configuration is used when adding
216278
items to collections. *Note that collection support is currently incomplete
@@ -270,26 +332,26 @@ setting is the ``plain_text_types``.
270332
));
271333
272334
``plain_text_types``
273-
""""""""""""""""""""
335+
....................
274336

275337
A list of RDFa field types that will be edited with a plain text editor without
276338
any formatting options. All other fields are edited with the WYSIWYG options
277339
activated.
278340

279341
``editor_base_path``
280-
""""""""""""""""""""
342+
....................
281343

282344
If you use a non-standard setup, you can adjust the editor base path
283345
configuration. This is only relevant for CKEditor.
284346

285347
``fixed_toolbar``
286-
"""""""""""""""""
348+
.................
287349

288350
Fix the editor toolbar on top of the page. Currently only supported by the
289351
hallo.js editor.
290352

291353
``stanbol_url``
292-
"""""""""""""""
354+
...............
293355

294356
Apache stanbol can be used for semantic enhancement of content. This feature
295357
can optionally be used with the hallo.js editor.

bundles/create/introduction.rst

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,18 +519,49 @@ Mapping Requests to Domain Objects
519519
One last piece is the mapping between CreatePHP data and the application
520520
domain objects. Data needs to be stored back into the database.
521521

522-
Currently, the CreateBundle only provides a service to map to Doctrine
523-
PHPCR-ODM. If you do not enable the phpcr persistence layer, you need to
524-
configure the ``cmf_create.object_mapper_service_id``.
522+
.. versionadded:: 1.3
523+
The chain mapper and ORM configuration was introduced in CreateBundle
524+
1.3. Prior, only the PHPCR-ODM mapper was available.
525525

526-
.. tip::
526+
Adding Custom Mappers to the Chain
527+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
528+
529+
The CreateBundle provides a chain mapper service that supports multiple mappers.
530+
Mappers for Doctrine PHPCR-ODM and Doctrine ORM are provided and can be enabled
531+
via :ref:`persistence configuration <config-create-persistence>`.
532+
533+
You may provide mappers to the chain mapper in addition to or in place of
534+
the provided mappers. They must implement ``Midgard\CreatePHP\RdfChainableMapperInterface``
535+
and be tagged with ``create_cmf.mapper``. You may provide the tag with an
536+
alias which will be prepended to subjects, the RDFa about field. If an alias
537+
is not provided, the service's id will be used instead.
538+
539+
.. configuration-block::
540+
541+
.. code-block:: yaml
542+
543+
services:
544+
app.elasticsearch_mapper:
545+
class: "AppBundle\Mapper\ElasticSearchMapper"
546+
tags:
547+
- { name: create_cmf.mapper, alias: elasticsearch }
548+
549+
.. code-block:: xml
550+
551+
<service id="app.elasticsearch_mapper" class="AppBundle\Mapper\ElasticSearchMapper">
552+
<tag name="create_cmf.mapper" alias="elasticsearch" />
553+
<!-- ... -->
554+
</service>
555+
556+
.. code-block:: php
527557
528-
Doctrine ORM support is coming soon. There is an open pull request on the
529-
CreatePHP library to add such a mapper. This mapper will also be provided
530-
as a service by the CreateBundle 1.1.
558+
$container
559+
->register('app.elasticsearch_mapper', 'AppBundle\Mapper\ElasticSearchMapper')
560+
->addTag('create_cmf.mapper', array('alias' => 'elasticsearch'))
561+
;
531562
532-
CreatePHP would support specific mappers per RDFa type. If you need that, dig
533-
into the CreatePHP and CreateBundle and do a pull request to enable this feature.
563+
You may instead set :ref:`config-create-object-mapper-service-id` and use
564+
your own mapper in place of the chain mapper.
534565

535566
Workflows
536567
---------

0 commit comments

Comments
 (0)