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

Commit 995113b

Browse files
committed
improve after feedback
1 parent 2d5f989 commit 995113b

File tree

4 files changed

+78
-58
lines changed

4 files changed

+78
-58
lines changed

bundles/block/cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ which returns:
189189
* ``block_id``
190190
* ``updated_at``
191191

192-
.. warning::
192+
.. caution::
193193

194194
If block settings need to be persisted between requests, it is advised to
195195
store them in the block document. If you add them to the cache keys, you

bundles/block/create_your_own_blocks.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ create a service that knows how to handle ``RssBlocks``:
8787
$block = $blockContext->getBlock();
8888

8989
if (!$block->getEnabled()) {
90-
return new Response;
90+
return new Response();
9191
}
9292

9393
$requestParams = $block->resolveRequestParams($this->request, $blockContext);

bundles/block/introduction.rst

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -83,63 +83,14 @@ specific settings for one of the block classes.
8383
),
8484
));
8585
86-
Sonata Admin Extension for basic block settings
87-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86+
.. tip::
8887

89-
If instead of (or in addition to) configuring block settings you want to make
90-
them editable in sonata admin, there is a sonata admin extension you can
91-
activate. This extension will add a tab to edit settings of base block options
92-
like the TTL (time to life, for caching purposes) editable.
88+
You can also store settings in the single block objects themselves. This
89+
allows to individually configure options per block instance.
9390

94-
Assuming your blocks extend the ``BaseBlock`` class, you can add the following
95-
lines to your sonata admin configuration.
96-
97-
.. configuration-block::
98-
99-
.. code-block:: yaml
100-
101-
# app/config/config.yml
102-
sonata_admin:
103-
extensions:
104-
cmf.block.admin.base.extension:
105-
extends:
106-
- Symfony\Cmf\Bundle\BlockBundle\Model\BaseBlock
107-
108-
.. code-block:: xml
109-
110-
<!-- app/config/config.xml -->
111-
<?xml version="1.0" encoding="UTF-8" ?>
112-
<container xmlns="http://symfony.com/schema/dic/services"
113-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
114-
115-
<config xmlns="http://sonata-project.org/schema/dic/admin">
116-
<extension id="cmf.block.admin.base.extension">
117-
<extend>Symfony\Cmf\Bundle\BlockBundle\Model\BaseBlock</extend>
118-
</extension>
119-
</config>
120-
</container>
121-
122-
.. code-block:: php
123-
124-
// app/config/config.php
125-
$container->loadFromExtension('sonata_admin', array(
126-
'extensions' => array(
127-
'cmf.block.admin.base.extension' => array(
128-
'extends' => array(
129-
'Symfony\Cmf\Bundle\BlockBundle\Model\BaseBlock',
130-
),
131-
),
132-
),
133-
));
134-
135-
.. note::
136-
137-
Admin extensions are a way to configure editing of common features on several
138-
``Admin`` classes without needing them to extend each other. If you want to
139-
learn more about them, please read on in `Sonata Admin Extensions`_ for more
140-
details.
141-
142-
.. _bundle-block-updated-sonata-defaults:
91+
If you edit the blocks using the Sonata admin, there is also the
92+
:ref:`Block Sonata Admin Extension <bundles-block-types-admin_extension>`
93+
that adds editing of the ``BaseBlock`` general block options.
14394

14495
Updated SonataBlockBundle Defaults
14596
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -411,4 +362,3 @@ Read on
411362
.. _`Symfony CMF Sandbox`: https://github.com/symfony-cmf/cmf-sandbox
412363
.. _`prepended configuration`: http://symfony.com/doc/current/components/dependency_injection/compilation.html#prepending-configuration-passed-to-the-extension
413364
.. _`SonataBlockBundle`: https://github.com/sonata-project/SonataBlockBundle
414-
.. _`Sonata Admin Extensions`: http://sonata-project.org/bundles/admin/master/doc/reference/extensions.html

bundles/block/types.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,75 @@ The ``AbstractBlock`` implements the write interfaces for publishable and publis
2424
period, see the :ref:`publish workflow documentation <bundle-core-publish-workflow>`
2525
for more information.
2626

27+
Sonata Admin
28+
~~~~~~~~~~~~
29+
30+
All block types provided by the Symfony2 CMF BlockBundle come with a admin
31+
classes for :doc:`../doctrine_phpcr_admin`. To activate the admin services,
32+
it is enough to load the SonataDoctrinePhpcrAdminBundle in your application
33+
kernel and configure the sonata dashboard as desired.
34+
35+
.. _bundles-block-types-admin_extension:
36+
37+
Sonata Admin Extension for Basic Block Settings
38+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39+
40+
This bundle also provides a sonata admin *extension* that you can activate.
41+
It adds a tab to edit settings of basic block options like the time to life
42+
(TTL, for caching purposes).
43+
44+
Assuming your blocks extend the ``BaseBlock`` class (as all blocks provided by
45+
the CMF BlockBundle do), you can add the following lines to your sonata admin
46+
configuration.
47+
48+
.. configuration-block::
49+
50+
.. code-block:: yaml
51+
52+
# app/config/config.yml
53+
sonata_admin:
54+
extensions:
55+
cmf.block.admin.base.extension:
56+
extends:
57+
- Symfony\Cmf\Bundle\BlockBundle\Model\BaseBlock
58+
59+
.. code-block:: xml
60+
61+
<!-- app/config/config.xml -->
62+
<?xml version="1.0" encoding="UTF-8" ?>
63+
<container xmlns="http://symfony.com/schema/dic/services"
64+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
65+
66+
<config xmlns="http://sonata-project.org/schema/dic/admin">
67+
<extension id="cmf.block.admin.base.extension">
68+
<extend>Symfony\Cmf\Bundle\BlockBundle\Model\BaseBlock</extend>
69+
</extension>
70+
</config>
71+
</container>
72+
73+
.. code-block:: php
74+
75+
// app/config/config.php
76+
$container->loadFromExtension('sonata_admin', array(
77+
'extensions' => array(
78+
'cmf.block.admin.base.extension' => array(
79+
'extends' => array(
80+
'Symfony\Cmf\Bundle\BlockBundle\Model\BaseBlock',
81+
),
82+
),
83+
),
84+
));
85+
86+
.. note::
87+
88+
Admin extensions are a way to configure editing of common features on several
89+
``Admin`` classes without needing them to extend each other. If you want to
90+
learn more about them, please read on in `Sonata Admin Extensions`_ for more
91+
details.
92+
93+
.. _bundle-block-updated-sonata-defaults:
94+
95+
2796
StringBlock
2897
-----------
2998

@@ -335,6 +404,7 @@ for further information.
335404

336405
.. _`Symfony CMF Sandbox`: https://github.com/symfony-cmf/cmf-sandbox
337406
.. _`Sonata Admin documentation`: http://sonata-project.org/bundles/admin/master/doc/reference/form_types.html
407+
.. _`Sonata Admin Extensions`: http://sonata-project.org/bundles/admin/master/doc/reference/extensions.html
338408
.. _`LiipImagineBundle`: https://github.com/liip/LiipImagineBundle
339409
.. _`LiipImagineBundle documentation`: https://github.com/liip/LiipImagineBundle/tree/master/Resources/doc
340410
.. _`sub-request`: http://symfony.com/doc/current/book/internals.html#internal-requests

0 commit comments

Comments
 (0)