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

Commit 84e6281

Browse files
authored
change block doc to best practices (#794)
1 parent d82a76d commit 84e6281

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

bundles/block/create_your_own_blocks.rst

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ the location where the RSS feed should be shown. The easiest way is to extend
3030
free to do create your own document. At least, you have to implement
3131
``Sonata\BlockBundle\Model\BlockInterface``. In your document, you
3232
need to define the ``getType`` method which returns the type name of your block,
33-
for instance ``acme_main.block.rss``::
33+
for instance ``rss_block``::
3434

35-
// src/Acme/MainBundle/Document/RssBlock.php
36-
namespace Acme\MainBundle\Document;
35+
// src/AppBundle/Document/RssBlock.php
36+
namespace AppBundle\Document;
3737

3838
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
3939

@@ -56,7 +56,7 @@ for instance ``acme_main.block.rss``::
5656

5757
public function getType()
5858
{
59-
return 'acme_main.block.rss';
59+
return 'app.rss_block';
6060
}
6161

6262
public function getOptions()
@@ -97,8 +97,8 @@ services provided by the CmfBlockBundle are in the namespace
9797
For your RSS block, you need a custom service
9898
that knows how to fetch the feed data of an ``RssBlock``::
9999

100-
// src/Acme/MainBundle/Block/RssBlockService.php
101-
namespace Acme\MainBundle\Block;
100+
// src/AppBundle/Block/RssBlockService.php
101+
namespace AppBundle\Block;
102102

103103
use Symfony\Component\HttpFoundation\Response;
104104
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
@@ -125,7 +125,8 @@ that knows how to fetch the feed data of an ``RssBlock``::
125125
$resolver->setDefaults(array(
126126
'url' => false,
127127
'title' => 'Feed items',
128-
'template' => 'AcmeMainBundle:Block:rss.html.twig',
128+
// template is at app/Resources/views/block/rss.html.twig
129+
'template' => 'block/rss.html.twig',
129130
));
130131
}
131132

@@ -308,33 +309,37 @@ handles, as per the ``getType`` method of the block. The second argument is the
308309

309310
.. code-block:: yaml
310311
311-
sandbox_main.block.rss:
312-
class: Acme\MainBundle\Block\RssBlockService
313-
arguments:
314-
- "acme_main.block.rss"
315-
- "@templating"
316-
tags:
317-
- {name: "sonata.block"}
312+
# app/config/services.yml
313+
services:
314+
app.rss_block:
315+
class: AppBundle\Block\RssBlockService
316+
arguments:
317+
- "app.rss_block"
318+
- "@templating"
319+
tags:
320+
- { name: "sonata.block" }
318321
319322
.. code-block:: xml
320323
321-
<service id="sandbox_main.block.rss" class="Acme\MainBundle\Block\RssBlockService">
324+
<!-- app/config/services.xml -->
325+
<service id="app.rss_block" class="AppBundle\Block\RssBlockService">
322326
<tag name="sonata.block" />
323327
324-
<argument>acme_main.block.rss</argument>
328+
<argument>app.rss_block</argument>
325329
<argument type="service" id="templating" />
326330
</service>
327331
328332
.. code-block:: php
329333
334+
// app/config/services.php
330335
use Symfony\Component\DependencyInjection\Definition;
331336
use Symfony\Component\DependencyInjection\Reference;
332337
333338
$container
334-
->addDefinition('sandbox_main.block.rss', new Definition(
335-
'Acme\MainBundle\Block\RssBlockService',
339+
->addDefinition('app.rss_block', new Definition(
340+
'AppBundle\Block\RssBlockService',
336341
array(
337-
'acme_main.block.rss',
342+
'app.rss_block',
338343
new Reference('templating'),
339344
)
340345
))

bundles/block/introduction.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BlockBundle
99
manage fragments of content, so-called blocks, that are persisted in a
1010
database and can be incorporated into any page layout.
1111

12-
The Symfony2 CMF BlockBundle also provides a few commonly used standard blocks,
12+
The CmfBlockBundle also provides a few commonly used standard blocks,
1313
including the ability to edit them. See :doc:`types`.
1414

1515
Installation
@@ -98,7 +98,7 @@ specific settings for one of the block classes.
9898
# app/config/config.yml
9999
sonata_block:
100100
blocks:
101-
acme_main.block.news:
101+
app.news_block:
102102
settings:
103103
maxItems: 3
104104
blocks_by_class:
@@ -113,7 +113,7 @@ specific settings for one of the block classes.
113113
<container xmlns="http://symfony.com/schema/dic/services">
114114
115115
<config xmlns="http://sonata-project.com/schema/dic/block">
116-
<blocks id="acme_main.block.rss">
116+
<blocks id="app.news_block">
117117
<setting id="maxItems">3</setting>
118118
</blocks>
119119
<block-by-class class="Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock">
@@ -127,7 +127,7 @@ specific settings for one of the block classes.
127127
// app/config/config.php
128128
$container->loadFromExtension('sonata_block', array(
129129
'blocks' => array(
130-
'acme_main.block.rss' => array(
130+
'app.news_block' => array(
131131
'settings' => array(
132132
'maxItems' => 3,
133133
),

0 commit comments

Comments
 (0)