The SimpleCmsBundle provides 2 ways of creating pages:
1. Creating a yaml file which will be parsed
This is done by a DataFixture. The AcmeDemoBundle comes with such a yaml file, which you can use to add your own page:
# src/Acme/MainBundle/Resources/data/page.yml
static:
# ...
my_new_page:
name: "my_page"
label: "My Page"
title: "My new Page"
body: "I've added this when following instructions on SO"
Now you need to execute php app/console doctrine:phpcr:fixtures:load
, which will execute the DataFixtures, and the new page is created!
2. Persisting the documents
What's really done with the yaml data is that a Page
document is created and persisted in the PHPCR tree. Inside a DataFixture, or in a controller/admin where you want to add a page, do the following:
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
// ...
$page = new Page();
$page->setName('my_other_page');
$page->setLabel('My other Page');
$page->setTitle('My other Page');
$page->setBody('I\'ve added this myself!!');
$documentManager = ...; // get the document manager, the first argument of DataFixture::load or $container->get('doctrine_phpcr')->getManager()
$root = $documentManager->find(null, '/cms/simple'); // get the root document
$page->setParent($root); // add document to the root
$documentManager->persist($page); // add the page in the queue for persisting
$documentManager->flush(); // execute the queries
For more information: http://symfony.com/doc/current/cmf/book/database_layer.html