Skip to content

Instantly share code, notes, and snippets.

@egulias
Created July 31, 2012 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egulias/3221440 to your computer and use it in GitHub Desktop.
Save egulias/3221440 to your computer and use it in GitHub Desktop.
Test controller ofr CMF Routes
public function indexAction()
{
$dm = $this->get('doctrine_phpcr.odm.document_manager');
$this->session = $this->container->get('doctrine_phpcr.default_session');
$base_path = $this->container->getParameter('symfony_cmf_routing_extra.routing_repositoryroot');
$content_path = $this->container->getParameter('symfony_cmf_content.static_basepath');
if ($this->session->itemExists($base_path)) {
$this->session->removeItem($base_path);
}
$this->createPath(dirname($base_path));
$root = $dm->find(null, dirname($base_path));
$parent = new MultilangLanguageSelectRoute();
$parent->setPosition($root, basename($base_path));
$dm->persist($parent);
$home = new DMRoute;
$home->setPosition($parent, 'es');
$home->setDefault('_locale', 'es');
$home->setRouteContent($dm->find(null, "/my-name"));
$dm->persist($home);
$dm->flush();
$root = $dm->find(null, '/cms/routes');
//Exception trying to get property of a non Object, routes is NULL
var_dump($root->getRoutes());die;
return array('name' => 'admin');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment