14.06.2013 Views

The Symfony CMF Book

The Symfony CMF Book

The Symfony CMF Book

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Listing 5-4<br />

Listing 5-5<br />

<strong>The</strong>se configuration parameters will be used to instantiate Route Enhancers. More information about<br />

them can be found in the Routing component documentation page.<br />

<strong>The</strong> specific example above determines that content instances of class Page will be rendered using the<br />

above template, if none other is explicitly provided by the associated Route (which, in this case, is Page<br />

itself). It also states that all content documents that instantiate RedirectRoute will be rendered using the<br />

specified Controller instead of the the default. Again, the actual Route can provided a controller that<br />

will take priority over this one. Both the template and the controller are part of SimpleCMSBundle.<br />

Menu Generation<br />

As mentioned before, Page implements NodeInterface, which means it can be used to generate a<br />

MenuItem that will, in turn, be rendered into HTML menus.<br />

To do so, the default MenuBundle mechanisms are used, only a custom basepath is provided to the<br />

PHPCRMenuProvider instance. This is defined in the SimpleCMSBundle configuration options, and used<br />

when handling content storage to support functionality as described in Menu documentation. This<br />

parameter is optional, and can be configured as follows:<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

# app/config/config.yml<br />

cmf_simple_cms:<br />

# defaults to auto; true/false can be used to force providing/not providing a menu<br />

use_menu: ~<br />

# defaults to /cms/simple<br />

basepath: ~<br />

Admin Support<br />

<strong>The</strong> SimpleCMSBundle also includes the administration panel and respective service needed for<br />

integration with SonataDoctrinePHPCRAdminBundle 1 , a backend editing bundle. For more information<br />

about it, please refer to the bundle's documentation section 2 .<br />

<strong>The</strong> included administration panels will automatically be loaded if you install the<br />

SonataDoctrinePHPCRAdminBundle (refer to ../tutorials/creating-cms-using-cmf-and-sonata<br />

for instructions on how to do so). You can change this behaviour with the following configuration<br />

option:<br />

1<br />

2<br />

3<br />

4<br />

# app/config/config.yml<br />

cmf_simple_cms:<br />

# defaults to auto; true/false can be used to force using/not using SonataAdmin<br />

use_sonata_admin: ~<br />

Fixtures<br />

<strong>The</strong> SimpleCMSBundle includes a support class for integration with DoctrineFixturesBundle 3 , aimed at<br />

making loading initial data easier. A working example is provided in <strong>Symfony</strong> <strong>CMF</strong> SE that illustrates<br />

how you can easily generate MultilangPage and MultilangMenuNode instances from YAML files.<br />

1. https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle<br />

2. https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/tree/master/Resources/doc<br />

3. http://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html<br />

PDF brought to you by<br />

generated on June 13, 2013<br />

Chapter 5: SimpleCMS | 22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!