symfony-cmf/BlockBundle — pull request #54 by fazy (2013-04-23 11:22:42+00:00)
Title: [WIP] Made document manager configurable for block loader

Allow templates that use PHPCRBlockLoader to specify which document manager should be used to find the document.

This is to allow the same template to view content from different workspaces. For example, if two document managers are configured, "preview" and "published", each corresponding to a different workspace, then it should be possible to load content from one workspace or the other.

In Twig:

{{ sonata_block_render({
'name': '/path/to/block',
'manager': 'preview'
}) }}

I've considered other ways to achieve this. I could define a second PHPCRBlockLoader service with the second document manager, but I'm not sure how to ensure the correct one picks up the block. Alternatively, I could extend this loader class, have my own `load()` method set up the DM and then call `parent::load()`.

The changes I've made *should* cause no problems, although it's always possible someone's extended the class and called `findByName()` without calling `load()` first. If that's a concern, I could restore the line setting `$this->dm` in the constructor so that member is never empty.

Marked this as [WIP] because I still need to update the unit tests, if this looks like it's an appropriate addition.