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

Block - move mappings to xml #199

Merged
merged 3 commits into from
Aug 6, 2013
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
2 changes: 1 addition & 1 deletion bundles/block/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ CmfBlockBundle and the SonataBlockBundle:
cache: cmf.block.cache.js_async
blocks_by_class:
# cache only the RssBlock and not all action blocks
Symfony\Cmf\Bundle\BlockBundle\Document\RssBlock:
Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock:
cache: cmf.block.cache.js_async

.. code-block:: xml
Expand Down
6 changes: 3 additions & 3 deletions bundles/block/create_your_own_blocks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Create a block document
-----------------------

The first thing you need is an document that contains the data. It is
recommended to extend ``Symfony\Cmf\Bundle\BlockBundle\Document\BaseBlock``
recommended to extend ``Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock``
contained in this bundle (however you are not forced to do so, as long as you
implement ``Sonata\BlockBundle\Model\BlockInterface``). In your document, you
need to define the ``getType`` method which just returns ``acme_main.block.rss``.
Expand All @@ -30,14 +30,14 @@ need to define the ``getType`` method which just returns ``acme_main.block.rss``
namespace Acme\MainBundle\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Symfony\Cmf\Bundle\BlockBundle\Document\BaseBlock;
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock;

/**
* Rss Block
*
* @PHPCRODM\Document(referenceable=true)
*/
class RssBlock extends BaseBlock
class RssBlock extends AbstractBlock
{
public function getType()
{
Expand Down
35 changes: 9 additions & 26 deletions bundles/block/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,10 @@ The configuration key for this bundle is ``cmf_block``:

# app/config/config.yml
cmf_block:
manager_name: default

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:cmf-block="http://cmf.symfony.com/schema/dic/block"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<cmf-block:config
document-manager-name="default"
/>
</container>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('cmf_block', array(
'document_manager_name' => 'default',
));
persistence:
phpcr:
enabled: true
manager_name: default

The default settings of a block are defined in the block service. If you use a
3rd party block you might want to alter these for your application. Use the
Expand All @@ -89,7 +72,7 @@ specific settings for one of the block classes.
settings:
maxItems: 3
blocks_by_class:
Symfony\Cmf\Bundle\BlockBundle\Document\RssBlock:
Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock:
settings:
maxItems: 3

Expand Down Expand Up @@ -170,22 +153,22 @@ Block Document
Before you can render a block, you need to create a data object representing
your block in the repository. You can do so with the following code snippet::

use Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock;
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock;

// ...

$myBlock = new SimpleBlock();
$myBlock->setParentDocument($parentDocument);
$myBlock->setName('sidebarBlock');
$myBlock->setTitle('My first block');
$myBlock->setContent('Hello block world!');
$myBlock->setBody('Hello block world!');

$documentManager->persist($myBlock);

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

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

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

Block Context
-------------
Expand Down
10 changes: 5 additions & 5 deletions bundles/block/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ StringBlock
-----------

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

SimpleBlock
-----------

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

Expand Down Expand Up @@ -78,7 +78,7 @@ display them in a list.

Create a document::

use Symfony\Cmf\Bundle\BlockBundle\Document\RssBlock;
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock;

// ...

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

use Symfony\Cmf\Bundle\BlockBundle\Document\SlideshowBlock;
use Symfony\Cmf\Bundle\BlockBundle\Document\ImagineBlock;
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SlideshowBlock;
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ImagineBlock;
// the Image will be moved to Symfony\Cmf\Bundle\MediaBundle\Model\Image
use Doctrine\ODM\PHPCR\Document\Image;
use Doctrine\ODM\PHPCR\Document\File;
Expand Down
10 changes: 5 additions & 5 deletions bundles/tree_browser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ This configuration is set for all your application trees regardless their type
- all
Symfony\Cmf\Bundle\ContentBundle\Document\MultilangStaticContent:
valid_children:
- Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock
- Symfony\Cmf\Bundle\BlockBundle\Document\ContainerBlock
- Symfony\Cmf\Bundle\BlockBundle\Document\ReferenceBlock
- Symfony\Cmf\Bundle\BlockBundle\Document\ActionBlock
Symfony\Cmf\Bundle\BlockBundle\Document\ReferenceBlock:
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ReferenceBlock
- Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ActionBlock
Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ReferenceBlock:
valid_children: []
# ...

Expand Down
12 changes: 6 additions & 6 deletions tutorials/using_blockbundle_and_contentbundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ like this::
$myBlock->setParentDocument($parentPage);
$myBlock->setName('sidebarBlock');
$myBlock->setTitle('My first block');
$myBlock->setContent('Hello block world!');
$myBlock->setBody('Hello block world!');

$documentManager->persist($myBlock);

Expand Down Expand Up @@ -259,7 +259,7 @@ your ``DataFixtures/PHPCR`` directory::
use Doctrine\ODM\PHPCR\Document\Generic;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock;
use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock;

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

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

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

// Commit $document and $block to the database
Expand Down Expand Up @@ -662,7 +662,7 @@ SimpleBlock class not found
.. code-block:: text

[Doctrine\Common\Persistence\Mapping\MappingException]
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
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

Make sure the CMF BlockBundle is installed and loaded in ``app/AppKernel.php``::

Expand Down