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

Commit d9cb711

Browse files
authored
Merge pull request #810 from symfony-cmf/bp-content
[content] change doc to best practices
2 parents 92e6058 + 5958a46 commit d9cb711

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

bundles/content/configuration.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ is the following configuration:
3030

3131
.. code-block:: yaml
3232
33+
# app/config/config.yml
3334
cmf_content:
3435
persistence:
3536
phpcr:
@@ -41,6 +42,7 @@ is the following configuration:
4142
4243
.. code-block:: xml
4344
45+
<!-- app/config/config.xml -->
4446
<?xml version="1.0" charset="UTF-8" ?>
4547
<container xmlns="http://symfony.com/schema/dic/services">
4648
@@ -60,15 +62,18 @@ is the following configuration:
6062
6163
.. code-block:: php
6264
63-
$container->loadFromExtension('cmf_content', array(
64-
'persistence' => array(
65-
'phpcr' => array(
65+
// app/config/config.php
66+
$container->loadFromExtension('cmf_content', [
67+
'persistence' => [
68+
'phpcr' => [
6669
'enabled' => false,
6770
'admin_class' => null,
6871
'document_class' => null,
6972
'content_basepath' => '/cms/content',
7073
'use_sonata_admin' => 'auto',
71-
));
74+
],
75+
],
76+
]);
7277
7378
``enabled``
7479
...........

bundles/content/exposing_content_via_rest.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Here is an example configuration for the FOSRestBundle.
5454

5555
.. code-block:: yaml
5656
57+
# app/config/config.yml
5758
fos_rest:
5859
# configure the view handler
5960
view:
@@ -71,6 +72,7 @@ Here is an example configuration for the FOSRestBundle.
7172
7273
.. code-block:: xml
7374
75+
<!-- app/config/config.xml -->
7476
<?xml version="1.0" encoding="UTF-8" ?>
7577
<container xmlns="http://symfony.com/schema/dic/services">
7678
@@ -98,46 +100,46 @@ Here is an example configuration for the FOSRestBundle.
98100
99101
.. code-block:: php
100102
101-
$container->loadFromExtension('fos_rest', array(
103+
// app/config/config.php
104+
$container->loadFromExtension('fos_rest', [
102105
// configure the view handler
103-
'view' => array(
104-
'force_redirects' => array(
106+
'view' => [
107+
'force_redirects' => [
105108
'html' => true,
106-
),
107-
'formats' => array(
109+
],
110+
'formats' => [
108111
'json' => true,
109112
'xml' => true,
110-
),
111-
'templating_formats' => array(
113+
],
114+
'templating_formats' => [
112115
'html' => true,
113-
),
114-
),
116+
],
117+
],
115118
// add a content negotiation rule, enabling support for json/xml for the entire website
116-
'format_listener' => array(
117-
'rules' => array(
118-
array(
119+
'format_listener' => [
120+
'rules' => [
121+
[
119122
'path' => '^/',
120-
'priorities' => array('html', 'json', 'xml'),
123+
'priorities' => ['html', 'json', 'xml'],
121124
'fallback_format' => 'html',
122125
'prefer_extension' => false,
123-
),
124-
),
125-
),
126-
));
126+
],
127+
],
128+
],
129+
]);
127130
128131
Using the REST API
129132
------------------
130133

131-
After you configured the FOSRestBundle, you need to execute the following
132-
commands:
134+
This is all it takes to enable read support via JSON or XML!
135+
Test if the setup works as expected with curl:
133136

134137
.. code-block:: bash
135138
136139
curl http://my-cmf.org/app_dev.php -H Accept:application/json
137140
curl http://my-cmf.org/app_dev.php -H Accept:application/xml
138141
curl http://my-cmf.org/app_dev.php -H Accept:text/html
139142
140-
This is all it takes to enable read support via JSON or XML!
141143
142144
The JMS serializer comes with sensible defaults for Doctrine object mappers.
143145
However it might be necessary to add additional mapping to more tightly

bundles/content/introduction.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ To configure a default template, use the ``default_template`` option:
140140
// app/config/config.yml
141141
142142
// ...
143-
$container->loadFromExtension('cmf_content', array(
143+
$container->loadFromExtension('cmf_content', [
144144
'default_template' => 'AppBundle:Content:static.html.twig',
145-
));
145+
]);
146146
147147
Whenever the content controller gets called without a specified template, it
148148
will now use this template.
@@ -187,16 +187,16 @@ Lets assume that you want to handle ``StaticContent`` with the default
187187
188188
.. code-block:: php
189189
190-
// app/config/config.yml
191-
190+
// app/config/config.php
191+
use Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent;
192192
// ...
193-
$container->loadFromExtension('cmf_routing', array(
194-
'dynamic' => array(
195-
'controller_by_class' => array(
196-
'Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent' => 'cmf_content.controller:indexAction',
197-
),
198-
),
199-
));
193+
$container->loadFromExtension('cmf_routing', [
194+
'dynamic' => [
195+
'controller_by_class' => [
196+
StaticContent::class => 'cmf_content.controller:indexAction',
197+
],
198+
],
199+
]);
200200
201201
Now everything is configured correctly, navigating to ``/hello`` results in a
202202
page displaying your content.

0 commit comments

Comments
 (0)