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

Commit 5c5c3a6

Browse files
committed
Merge pull request #199 from rmsint/block_mappings
Block - move mappings to xml
2 parents 8222bbb + 976e6cc commit 5c5c3a6

File tree

6 files changed

+29
-46
lines changed

6 files changed

+29
-46
lines changed

bundles/block/cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CmfBlockBundle and the SonataBlockBundle:
8585
cache: cmf.block.cache.js_async
8686
blocks_by_class:
8787
# cache only the RssBlock and not all action blocks
88-
Symfony\Cmf\Bundle\BlockBundle\Document\RssBlock:
88+
Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock:
8989
cache: cmf.block.cache.js_async
9090
9191
.. code-block:: xml

bundles/block/create_your_own_blocks.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Create a block document
1919
-----------------------
2020

2121
The first thing you need is an document that contains the data. It is
22-
recommended to extend ``Symfony\Cmf\Bundle\BlockBundle\Document\BaseBlock``
22+
recommended to extend ``Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock``
2323
contained in this bundle (however you are not forced to do so, as long as you
2424
implement ``Sonata\BlockBundle\Model\BlockInterface``). In your document, you
2525
need to define the ``getType`` method which just returns ``acme_main.block.rss``.
@@ -30,14 +30,14 @@ need to define the ``getType`` method which just returns ``acme_main.block.rss``
3030
namespace Acme\MainBundle\Document;
3131
3232
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
33-
use Symfony\Cmf\Bundle\BlockBundle\Document\BaseBlock;
33+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock;
3434
3535
/**
3636
* Rss Block
3737
*
3838
* @PHPCRODM\Document(referenceable=true)
3939
*/
40-
class RssBlock extends BaseBlock
40+
class RssBlock extends AbstractBlock
4141
{
4242
public function getType()
4343
{

bundles/block/introduction.rst

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,10 @@ The configuration key for this bundle is ``cmf_block``:
4949
5050
# app/config/config.yml
5151
cmf_block:
52-
manager_name: default
53-
54-
.. code-block:: xml
55-
56-
<!-- app/config/config.xml -->
57-
<?xml version="1.0" encoding="UTF-8" ?>
58-
<container xmlns="http://symfony.com/schema/dic/services"
59-
xmlns:cmf-block="http://cmf.symfony.com/schema/dic/block"
60-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
61-
62-
<cmf-block:config
63-
document-manager-name="default"
64-
/>
65-
</container>
66-
67-
.. code-block:: php
68-
69-
// app/config/config.php
70-
$container->loadFromExtension('cmf_block', array(
71-
'document_manager_name' => 'default',
72-
));
52+
persistence:
53+
phpcr:
54+
enabled: true
55+
manager_name: default
7356
7457
The default settings of a block are defined in the block service. If you use a
7558
3rd party block you might want to alter these for your application. Use the
@@ -89,7 +72,7 @@ specific settings for one of the block classes.
8972
settings:
9073
maxItems: 3
9174
blocks_by_class:
92-
Symfony\Cmf\Bundle\BlockBundle\Document\RssBlock:
75+
Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock:
9376
settings:
9477
maxItems: 3
9578
@@ -170,22 +153,22 @@ Block Document
170153
Before you can render a block, you need to create a data object representing
171154
your block in the repository. You can do so with the following code snippet::
172155

173-
use Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock;
156+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock;
174157

175158
// ...
176159

177160
$myBlock = new SimpleBlock();
178161
$myBlock->setParentDocument($parentDocument);
179162
$myBlock->setName('sidebarBlock');
180163
$myBlock->setTitle('My first block');
181-
$myBlock->setContent('Hello block world!');
164+
$myBlock->setBody('Hello block world!');
182165

183166
$documentManager->persist($myBlock);
184167

185168
Note the ``sidebarBlock`` is the identifier we chose for the block. Together
186169
with the parent document of the block, this makes the block unique. The other
187170
properties are specific to
188-
``Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock``.
171+
``Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock``.
189172

190173
The simple block is now ready to be rendered, see
191174
:ref:`bundle-block-rendering`.
@@ -194,7 +177,7 @@ The simple block is now ready to be rendered, see
194177

195178
Always make sure you implement the interface
196179
``Sonata\BlockBundle\Model\BlockInterface`` or an existing block document
197-
like ``Symfony\Cmf\Bundle\BlockBundle\Document\BaseBlock``.
180+
like ``Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock``.
198181

199182
Block Context
200183
-------------

bundles/block/types.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ StringBlock
1010
-----------
1111

1212
This is a very simple block that just provides one string field called
13-
``content`` and the default template renders the content as ``raw`` to
13+
``body`` and the default template renders the content as ``raw`` to
1414
allow HTML in the field. The template outputs no HTML tags around the string
1515
at all.
1616

1717
SimpleBlock
1818
-----------
1919

20-
Just a text block with a ``title`` and a ``content``. The default template
20+
Just a text block with a ``title`` and a ``body``. The default template
2121
renders both title and content as ``raw``, meaning HTML is allowed in those
2222
fields.
2323

@@ -78,7 +78,7 @@ display them in a list.
7878

7979
Create a document::
8080

81-
use Symfony\Cmf\Bundle\BlockBundle\Document\RssBlock;
81+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock;
8282

8383
// ...
8484

@@ -201,8 +201,8 @@ Creating a slideshow consists of creating the container ``SlideshowBlock`` and
201201
adding blocks to it. Those blocks can be anything, but an image makes a lot
202202
of sense::
203203

204-
use Symfony\Cmf\Bundle\BlockBundle\Document\SlideshowBlock;
205-
use Symfony\Cmf\Bundle\BlockBundle\Document\ImagineBlock;
204+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SlideshowBlock;
205+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ImagineBlock;
206206
// the Image will be moved to Symfony\Cmf\Bundle\MediaBundle\Model\Image
207207
use Doctrine\ODM\PHPCR\Document\Image;
208208
use Doctrine\ODM\PHPCR\Document\File;

bundles/tree_browser.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ This configuration is set for all your application trees regardless their type
157157
- all
158158
Symfony\Cmf\Bundle\ContentBundle\Document\MultilangStaticContent:
159159
valid_children:
160-
- Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock
161-
- Symfony\Cmf\Bundle\BlockBundle\Document\ContainerBlock
162-
- Symfony\Cmf\Bundle\BlockBundle\Document\ReferenceBlock
163-
- Symfony\Cmf\Bundle\BlockBundle\Document\ActionBlock
164-
Symfony\Cmf\Bundle\BlockBundle\Document\ReferenceBlock:
160+
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock
161+
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock
162+
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ReferenceBlock
163+
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ActionBlock
164+
Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ReferenceBlock:
165165
valid_children: []
166166
# ...
167167

tutorials/using_blockbundle_and_contentbundle.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ like this::
230230
$myBlock->setParentDocument($parentPage);
231231
$myBlock->setName('sidebarBlock');
232232
$myBlock->setTitle('My first block');
233-
$myBlock->setContent('Hello block world!');
233+
$myBlock->setBody('Hello block world!');
234234

235235
$documentManager->persist($myBlock);
236236

@@ -259,7 +259,7 @@ your ``DataFixtures/PHPCR`` directory::
259259
use Doctrine\ODM\PHPCR\Document\Generic;
260260
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
261261
use Symfony\Component\DependencyInjection\ContainerInterface;
262-
use Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock;
262+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock;
263263

264264
class LoadBlockWithPhpcrParent extends AbstractFixture implements ContainerAwareInterface
265265
{
@@ -279,7 +279,7 @@ your ``DataFixtures/PHPCR`` directory::
279279
$myBlock->setParentDocument($document);
280280
$myBlock->setName('testBlock');
281281
$myBlock->setTitle('CMF BlockBundle only');
282-
$myBlock->setContent('Block from CMF BlockBundle, parent from the PHPCR (Generic document).');
282+
$myBlock->setBody('Block from CMF BlockBundle, parent from the PHPCR (Generic document).');
283283
$manager->persist($myBlock);
284284

285285
// Commit $document and $block to the database
@@ -370,7 +370,7 @@ sample block, so create the ``LoadBlockWithCmfParent.php`` class::
370370
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
371371
use Symfony\Component\DependencyInjection\ContainerInterface;
372372
use PHPCR\Util\NodeHelper;
373-
use Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock;
373+
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock;
374374
use Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent;
375375

376376
class LoadBlockWithCmfParent extends AbstractFixture implements ContainerAwareInterface
@@ -394,7 +394,7 @@ sample block, so create the ``LoadBlockWithCmfParent.php`` class::
394394
$myBlock->setParentDocument($document);
395395
$myBlock->setName('testBlock');
396396
$myBlock->setTitle('CMF BlockBundle and ContentBundle');
397-
$myBlock->setContent('Block from CMF BlockBundle, parent from CMF ContentBundle (StaticContent).');
397+
$myBlock->setBody('Block from CMF BlockBundle, parent from CMF ContentBundle (StaticContent).');
398398
$manager->persist($myBlock);
399399

400400
// Commit $document and $block to the database
@@ -662,7 +662,7 @@ SimpleBlock class not found
662662
.. code-block:: text
663663
664664
[Doctrine\Common\Persistence\Mapping\MappingException]
665-
The class 'Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock' was not found in the chain configured namespaces Doctrine\ODM\PHPCR\Document, Sonata\UserBundle\Document, FOS\UserBundle\Document
665+
The class 'Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock' was not found in the chain configured namespaces Doctrine\ODM\PHPCR\Document, Sonata\UserBundle\Document, FOS\UserBundle\Document
666666
667667
Make sure the CMF BlockBundle is installed and loaded in ``app/AppKernel.php``::
668668

0 commit comments

Comments
 (0)