Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route::setPosition PHP Method

setPosition() public method

The url will be the url of the parent plus the supplied name.
public setPosition ( $parent, $name )
    public function setPosition($parent, $name)
    {
        if (!is_object($parent)) {
            throw new InvalidArgumentException('Parent must be an object ' . gettype($parent) . ' given.');
        }
        $this->parent = $parent;
        $this->name = $name;
        return $this;
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $session = $manager->getPhpcrSession();
     $basepath = $this->container->getParameter('cmf_routing.dynamic.persistence.phpcr.route_basepath');
     NodeHelper::createPath($session, $basepath);
     $routeRoot = $manager->find(null, $basepath);
     $basepath = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath');
     NodeHelper::createPath($session, $basepath);
     $parent = $manager->find(null, $basepath);
     $repository = $this->container->get('sylius.repository.page');
     // Terms of service.
     $route = new Route();
     $route->setPosition($routeRoot, 'terms-of-service');
     $manager->persist($route);
     $content = $repository->createNew();
     $content->setTitle('Terms of Service');
     $content->setBody($this->faker->text(350));
     $content->addRoute($route);
     $content->setParent($parent);
     $content->setName('terms-of-service');
     $manager->persist($content);
     // Contact.
     $route = new Route();
     $route->setPosition($routeRoot, 'about');
     $manager->persist($route);
     $content = $repository->createNew();
     $content->setTitle('About us');
     $content->setBody($this->faker->text(300));
     $content->addRoute($route);
     $content->setParent($parent);
     $content->setName('about-us');
     $manager->persist($content);
     $manager->flush();
 }
All Usage Examples Of Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route::setPosition