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

Commit 9ea2670

Browse files
committed
adjust for simplecms routing refactoring
1 parent 7c2a14b commit 9ea2670

File tree

4 files changed

+25
-114
lines changed

4 files changed

+25
-114
lines changed

book/simplecms.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ The SimpleCmsBundle provides a class called ``Page`` which extends from the core
3737
``NodeInterface``, so you can use inside the menu. This three-in-one approach is
3838
the key concept behind the bundle.
3939

40+
The mapping of the ``Page`` to a template and controller works as explained in
41+
the :doc:`previous chapter <routing>`.
42+
4043
Creating a new Page
4144
~~~~~~~~~~~~~~~~~~~
4245

@@ -49,7 +52,7 @@ To create a page, use the
4952
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
5053
use Doctrine\ODM\PHPCR\DocumentManager;
5154

52-
class LoadRoutingData implements FixtureInterface
55+
class LoadSimpleCms implements FixtureInterface
5356
{
5457
/**
5558
* @param DocumentManager $dm
@@ -79,7 +82,7 @@ have the following tree structure:
7982

8083
.. code-block:: text
8184
82-
/cmf/simple/
85+
/cms/simple/
8386
about/
8487
blog/
8588
symfony-cmf-is-great/
@@ -97,7 +100,7 @@ structure, you would do::
97100
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
98101
use Doctrine\ODM\PHPCR\DocumentManager;
99102

100-
class LoadRoutingData implements FixtureInterface
103+
class LoadSimpleCms implements FixtureInterface
101104
{
102105
/**
103106
* @param DocumentManager $dm
@@ -130,11 +133,11 @@ structure, you would do::
130133

131134
Every PHPCR-ODM document must have a parent document. Parents are never
132135
created automatically, so we use the PHPCR NodeHelper to ensure we have
133-
the root element (``/cmf/simple`` in this case).
136+
the root element (``/cms/simple`` in this case).
134137

135138
.. note::
136139

137-
The Page at ``/cmf/simple`` is created by an
140+
The Page at ``/cms/simple`` is created by an
138141
:ref:`initializer <phpcr-odm-repository-initializers>` of the
139142
SimpleCmsBundle.
140143

bundles/simple_cms/multilang.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ For example::
4343
``http://foo.com/en/hello-world`` for english content will look like
4444
``http://foo.com/de/hello-world`` for german content.
4545

46-
At times it might be most feasible to use integers as the node names and
47-
simple append the title of the node in the given locale as an anchor. So
48-
for example ``http://foo.com/de/1#my title`` and
49-
``http://foo.com/de/1#mein title``. If you need language specific URLs,
50-
you want to use the CMF RoutingBundle and ContentBundle directly to have
51-
a separate route document per language.
46+
If you need language specific URLs, you can either add Route documents for
47+
the other locales and configure the dynamic router to look for routes under
48+
both prefixes. You can also completely separate routing and content by using
49+
the separate documents from the RoutingBundle and ContentBundle.

bundles/simple_cms/rendering.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
Rendering
55
---------
66

7-
You can specify the template to render a page by setting the
8-
``_template`` default or by specifying the controller by setting the
9-
``_controller`` default in the page instance. Alternatively one can
7+
You can configure a mapping of document class to template and/or controller
8+
by configuring the :ref:`RoutingBundle <reference-config-routing-dynamic>`.
9+
When you need specific settings for a single page, you can call
10+
``setDefault()`` for the key ``_template`` or ``_controller`` default in the
11+
page instance.
12+
13+
Alternatively one can
1014
configure the template and controller also via the SimpleCmsBundle
1115
:ref:`routing configuration <config-simple-cms-routing>`.
1216

reference/configuration/simple_cms.rst

Lines changed: 6 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -179,112 +179,18 @@ Configure integration with CmfMenuBundle.
179179
'use_menu' => 'auto',
180180
));
181181
182-
.. _config-simple-cms-routing:
183-
184182
routing
185183
~~~~~~~
186184

187-
This configures how pages should be rendered. The simple cms uses its own
188-
instance of the ``DynamicRouter``. The options here are the same as described
189-
in :ref:`routing configuration <reference-config-routing-dynamic>`.
190-
191-
Pages that are loaded from the ``cmf_simple_cms.persistence.phpcr.basepath``
192-
need to be configured here. Pages loaded from the
193-
``cmf_routing.persistence.phpcr.basepath`` must be configured in the
194-
CmfRoutingBundle configuration.
195-
196-
.. configuration-block::
185+
.. versionadded:: 1.1
197186

198-
.. code-block:: yaml
199-
200-
cmf_simple_cms:
201-
routing:
202-
controller_by_alias: []
203-
controller_by_class: []
204-
templates_by_class:
205-
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page: CmfSimpleCmsBundle:Page:index.html.twig
206-
generic_controller: cmf_content.controller:indexAction
207-
content_repository_id: cmf_routing.content_repository
208-
uri_filter_regexp: ~
209-
210-
.. code-block:: xml
211-
212-
<?xml version="1.0" charset="UTF-8" ?>
213-
<container xmlns="http://symfony.com/schema/dic/services">
214-
215-
<config xmlns="http://cmf.symfony.com/schema/dic/simplecms">
216-
<routing xmlns="http://cmf.symfony.com/schema/dic/simplecms">
217-
<controller-by-alias></controller-by-alias>
218-
<controller-by-class></controller-by-class>
219-
<template-by-class alias="Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page">CmfSimpleCmsBundle:Page:index.html.twig</template-by-class>
220-
<generic-controller>cmf_content.controller:indexAction</generic-controller>
221-
<content-repository-id>cmf_routing.content_repository</content-repository-id>
222-
<uri-filter-regexp>null</uri-filter-regexp>
223-
</routing>
224-
</config>
225-
</container>
226-
227-
.. code-block:: php
228-
229-
$container->loadFromExtension('cmf_simple_cms', array(
230-
'routing' => array(
231-
'controller_by_alias' => array(),
232-
'controller_by_class' => array(),
233-
'templates_by_class' => array(
234-
'Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page' => 'CmfSimpleCmsBundle:Page:index.html.twig',
235-
),
236-
'generic_controller' => 'cmf_content.controller:indexAction',
237-
'content_repository_id' => 'cmf_routing.content_repository',
238-
'uri_filter_regexp' => null,
239-
),
240-
));
241-
242-
.. _config-simple_cms-multilang:
187+
Since SimpleCmsBundle 1.1, this configuration is done directly on the
188+
:ref:`RoutingBundle <reference-config-routing-dynamic>`.
243189

244190
multilang
245191
~~~~~~~~~
246192

247-
Multilanguage is activated if the ``locales`` option is configured (either in
248-
SimpleCmsBundle or in CoreBundle).
249-
250-
.. configuration-block::
251-
252-
.. code-block:: yaml
253-
254-
cmf_simple_cms:
255-
multilang:
256-
locales: [en, fr]
257-
258-
.. code-block:: xml
193+
.. versionadded:: 1.1
259194

260-
<?xml version="1.0" charset="UTF-8" ?>
261-
<container xmlns="http://symfony.com/schema/dic/services">
262-
263-
<config xmlns="http://cmf.symfony.com/schema/dic/simplecms">
264-
<multilang>
265-
<locales>en</locales>
266-
<locales>fr</locales>
267-
</multilang>
268-
</config>
269-
</container>
270-
271-
.. code-block:: php
272-
273-
$container->loadFromExtension('cmf_simple_cms', array(
274-
'multilang' => array(
275-
'locales' => array(
276-
'en',
277-
'fr',
278-
),
279-
),
280-
));
281-
282-
locales
283-
.......
284-
285-
**type**: ``array`` **default**: ``null``
286-
287-
This define languages that can be used.
288-
289-
If the :doc:`CoreBundle <../../bundles/core/index>` is registered, this will default to
290-
the value of ``cmf_core.multilang.locales``.
195+
Since SimpleCmsBundle 1.1, this configuration is done directly on the
196+
:ref:`RoutingBundle <reference-config-routing-locales>`.

0 commit comments

Comments
 (0)