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

Commit 0282c97

Browse files
committed
change block doc to best practices
1 parent d82a76d commit 0282c97

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

bundles/block/create_your_own_blocks.rst

Lines changed: 18 additions & 14 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 ``block.rss``::
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 'block.rss';
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,7 @@ 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' => 'AppBundle:Block:rss.html.twig',
129129
));
130130
}
131131

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

309309
.. code-block:: yaml
310310
311-
sandbox_main.block.rss:
312-
class: Acme\MainBundle\Block\RssBlockService
311+
# app/config/services.yml
312+
block.rss:
313+
class: AppBundle\Block\RssBlockService
313314
arguments:
314-
- "acme_main.block.rss"
315+
- "block.rss"
315316
- "@templating"
316317
tags:
317318
- {name: "sonata.block"}
318319
319320
.. code-block:: xml
320321
321-
<service id="sandbox_main.block.rss" class="Acme\MainBundle\Block\RssBlockService">
322+
<!-- app/config/services.xml -->
323+
<service id="sandbox_main.block.rss" class="AppBundle\Block\RssBlockService">
322324
<tag name="sonata.block" />
323325
324-
<argument>acme_main.block.rss</argument>
326+
<argument>block.rss</argument>
325327
<argument type="service" id="templating" />
326328
</service>
327329
328330
.. code-block:: php
329331
332+
// app/config/services.php
333+
330334
use Symfony\Component\DependencyInjection\Definition;
331335
use Symfony\Component\DependencyInjection\Reference;
332336
333337
$container
334338
->addDefinition('sandbox_main.block.rss', new Definition(
335-
'Acme\MainBundle\Block\RssBlockService',
339+
'AppBundle\Block\RssBlockService',
336340
array(
337-
'acme_main.block.rss',
341+
'block.rss',
338342
new Reference('templating'),
339343
)
340344
))

bundles/block/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
block.news:
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="block.rss">
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+
'block.rss' => array(
131131
'settings' => array(
132132
'maxItems' => 3,
133133
),

0 commit comments

Comments
 (0)