@@ -453,6 +453,7 @@ follows::
453
453
use Doctrine\Common\Persistence\ObjectManager;
454
454
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;
455
455
use Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent;
456
+ use PHPCR\Util\NodeHelper;
456
457
457
458
class LoadRoutingData implements FixtureInterface
458
459
{
@@ -466,6 +467,8 @@ follows::
466
467
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
467
468
}
468
469
470
+ NodeHelper::createPath($session, '/cms/routes');
471
+
469
472
$route = new Route();
470
473
$route->setParentDocument($dm->find(null, '/cms/routes'));
471
474
$route->setName('projects');
@@ -491,6 +494,15 @@ follows::
491
494
This will give you a document that matches the URL ``/projects/<number> `` but
492
495
also ``/projects `` as there is a default for the id parameter.
493
496
497
+ .. caution ::
498
+
499
+ As you can see, the code explicitely creates the ``/cms/routes `` path.
500
+ The RoutingBundle only creates this path automatically if the Sonata Admin
501
+ was enabled in the routing configuration using an :ref: `initializer
502
+ <phpcr-odm-repository-initializers>`. Otherwise, it'll assume you do
503
+ something yourself to create the path (by configuring an initializer or
504
+ doing it in a fixture like this).
505
+
494
506
Because you defined the ``{id} `` route parameter, your controller can expect an
495
507
``$id `` parameter. Additionally, because you called setRouteContent on the
496
508
route, your controller can expect the ``$contentDocument `` parameter.
0 commit comments