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

[content] change doc to best practices #810

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
13 changes: 9 additions & 4 deletions bundles/content/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ is the following configuration:

.. code-block:: yaml

# app/config/config.yml
cmf_content:
persistence:
phpcr:
Expand All @@ -41,6 +42,7 @@ is the following configuration:

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" charset="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

Expand All @@ -60,15 +62,18 @@ is the following configuration:

.. code-block:: php

$container->loadFromExtension('cmf_content', array(
'persistence' => array(
'phpcr' => array(
// app/config/config.php
$container->loadFromExtension('cmf_content', [
'persistence' => [
'phpcr' => [
'enabled' => false,
'admin_class' => null,
'document_class' => null,
'content_basepath' => '/cms/content',
'use_sonata_admin' => 'auto',
));
],
],
]);

``enabled``
...........
Expand Down
42 changes: 22 additions & 20 deletions bundles/content/exposing_content_via_rest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Here is an example configuration for the FOSRestBundle.

.. code-block:: yaml

# app/config/config.yml
fos_rest:
# configure the view handler
view:
Expand All @@ -71,6 +72,7 @@ Here is an example configuration for the FOSRestBundle.

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

Expand Down Expand Up @@ -98,46 +100,46 @@ Here is an example configuration for the FOSRestBundle.

.. code-block:: php

$container->loadFromExtension('fos_rest', array(
// app/config/config.php
$container->loadFromExtension('fos_rest', [
// configure the view handler
'view' => array(
'force_redirects' => array(
'view' => [
'force_redirects' => [
'html' => true,
),
'formats' => array(
],
'formats' => [
'json' => true,
'xml' => true,
),
'templating_formats' => array(
],
'templating_formats' => [
'html' => true,
),
),
],
],
// add a content negotiation rule, enabling support for json/xml for the entire website
'format_listener' => array(
'rules' => array(
array(
'format_listener' => [
'rules' => [
[
'path' => '^/',
'priorities' => array('html', 'json', 'xml'),
'priorities' => ['html', 'json', 'xml'],
'fallback_format' => 'html',
'prefer_extension' => false,
),
),
),
));
],
],
],
]);

Using the REST API
------------------

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

.. code-block:: bash

curl http://my-cmf.org/app_dev.php -H Accept:application/json
curl http://my-cmf.org/app_dev.php -H Accept:application/xml
curl http://my-cmf.org/app_dev.php -H Accept:text/html

This is all it takes to enable read support via JSON or XML!

The JMS serializer comes with sensible defaults for Doctrine object mappers.
However it might be necessary to add additional mapping to more tightly
Expand Down
22 changes: 11 additions & 11 deletions bundles/content/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ To configure a default template, use the ``default_template`` option:
// app/config/config.yml

// ...
$container->loadFromExtension('cmf_content', array(
$container->loadFromExtension('cmf_content', [
'default_template' => 'AppBundle:Content:static.html.twig',
));
]);

Whenever the content controller gets called without a specified template, it
will now use this template.
Expand Down Expand Up @@ -187,16 +187,16 @@ Lets assume that you want to handle ``StaticContent`` with the default

.. code-block:: php

// app/config/config.yml

// app/config/config.php
use Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent;
// ...
$container->loadFromExtension('cmf_routing', array(
'dynamic' => array(
'controller_by_class' => array(
'Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent' => 'cmf_content.controller:indexAction',
),
),
));
$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'controller_by_class' => [
StaticContent::class => 'cmf_content.controller:indexAction',
],
],
]);

Now everything is configured correctly, navigating to ``/hello`` results in a
page displaying your content.
Expand Down