Пример #1
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParentDocument($root);
     $parent->setNodename('routing');
     $manager->persist($parent);
     $routeCollection = new Route();
     $routeCollection->setParentDocument($parent);
     $routeCollection->setMethods(array('POST', 'GET', 'PUT'));
     # Todo check if we can add a type and set defaults prePersist?
     $routeCollection->setName('collection');
     $manager->persist($routeCollection);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('get-1');
     $route->setMethods(array(Request::METHOD_GET));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('post-1');
     $route->setMethods(array(Request::METHOD_POST));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('put-1');
     $route->setMethods(array(Request::METHOD_PUT));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('delete-1');
     $route->setMethods(array(Request::METHOD_DELETE));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('patch-1');
     $route->setMethods(array(Request::METHOD_PATCH));
     $manager->persist($route);
     $manager->flush();
 }
Пример #2
0
 /**
  * @expectedException \Symfony\Component\Routing\Exception\MethodNotAllowedException
  */
 public function testNotAllowed()
 {
     $root = $this->getDm()->find(null, self::ROUTE_ROOT);
     // do not set a content here, or we need a valid request and so on...
     $route = new Route();
     $route->setPosition($root, 'notallowed');
     $route->setMethods(array('GET'));
     $route->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController');
     $this->getDm()->persist($route);
     $this->getDm()->flush();
     $this->router->matchRequest(Request::create('/notallowed', 'POST'));
 }