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

Commit 1190ee6

Browse files
committed
Add CreateBundle chain mapper information
1 parent 92090aa commit 1190ee6

File tree

2 files changed

+114
-24
lines changed

2 files changed

+114
-24
lines changed

bundles/create/configuration.rst

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,29 @@ 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 provide a ``cmf_create.mapper`` tagged mapper for this
76+
bundle to work.
77+
6578
.. _config-create-persistence:
6679

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

7083
This defines the persistence driver and associated classes. The default
71-
persistence configuration has the following configuration:
84+
persistence configuration has the following configurations.
85+
86+
``phpcr``
87+
.........
7288

7389
.. configuration-block::
7490

@@ -127,13 +143,6 @@ persistence configuration has the following configuration:
127143
),
128144
));
129145
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.
137146
138147
``enabled``
139148
"""""""""""
@@ -164,6 +173,61 @@ Set delete to true to enable the simple delete workflow. This allows to directly
164173
delete content from the frontend. Be careful, there are no special checks once you confirm deletion
165174
your content is gone.
166175

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

@@ -198,19 +262,19 @@ Metadata Handling
198262
));
199263
200264
``auto_mapping``
201-
""""""""""""""""
265+
................
202266

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

206270
``rdf_config_dirs``
207-
"""""""""""""""""""
271+
...................
208272

209273
Additional directories to look for mapping files besides the auto mapped
210274
directory.
211275

212276
``map``
213-
"""""""
277+
.......
214278

215279
Mapping from RDF type name to class. This configuration is used when adding
216280
items to collections. *Note that collection support is currently incomplete
@@ -270,26 +334,26 @@ setting is the ``plain_text_types``.
270334
));
271335
272336
``plain_text_types``
273-
""""""""""""""""""""
337+
....................
274338

275339
A list of RDFa field types that will be edited with a plain text editor without
276340
any formatting options. All other fields are edited with the WYSIWYG options
277341
activated.
278342

279343
``editor_base_path``
280-
""""""""""""""""""""
344+
....................
281345

282346
If you use a non-standard setup, you can adjust the editor base path
283347
configuration. This is only relevant for CKEditor.
284348

285349
``fixed_toolbar``
286-
"""""""""""""""""
350+
.................
287351

288352
Fix the editor toolbar on top of the page. Currently only supported by the
289353
hallo.js editor.
290354

291355
``stanbol_url``
292-
"""""""""""""""
356+
...............
293357

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

bundles/create/introduction.rst

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,18 +511,44 @@ Mapping Requests to Domain Objects
511511
One last piece is the mapping between CreatePHP data and the application
512512
domain objects. Data needs to be stored back into the database.
513513

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

518-
.. tip::
518+
The CreateBundle provides a chain mapper service that supports multiple mappers.
519+
Mappers for Doctrine PHPCR-ODM and Doctrine ORM are provided and can be enabled
520+
via :ref:`persistence configuration <config-create-persistence>`.
521+
522+
You may provide mappers to the chain mapper in addition to or in place of the
523+
provided mappers. They must implement ``Midgard\CreatePHP\RdfChainableMapperInterface``
524+
and be tagged with ``create_cmf.mapper``.
525+
526+
.. configuration-block::
527+
528+
.. code-block:: yaml
529+
530+
services:
531+
acme_core.my_mapper:
532+
class: "%my_namespace.my_mapper_class%"
533+
tags:
534+
- { name: create_cmf.mapper, alias: my_mapper_alias }
535+
536+
.. code-block:: xml
537+
538+
<service id="acme_core.my_mapper" class="%my_namespace.my_mapper_class%">
539+
<tag name="create_cmf.mapper" alias="my_mapper_alias" />
540+
<!-- ... -->
541+
</service>
542+
543+
.. code-block:: php
519544
520-
Doctrine ORM support is coming soon. There is an open pull request on the
521-
CreatePHP library to add such a mapper. This mapper will also be provided
522-
as a service by the CreateBundle 1.1.
545+
$container
546+
->register('acme_core.my_mapper', '%my_namespace.my_mapper_class')
547+
->addTag('create_cmf.mapper', array('alias' => 'my_mapper_alias'))
548+
;
523549
524-
CreatePHP would support specific mappers per RDFa type. If you need that, dig
525-
into the CreatePHP and CreateBundle and do a pull request to enable this feature.
550+
You may instead set :ref:`config-create-object-mapper-service-id` and use
551+
your own mapper in place of the chain mapper.
526552

527553
Workflows
528554
---------

0 commit comments

Comments
 (0)