Fosrestbundle: Routing option "parent" does not work

Created on 24 Jul 2011  路  3Comments  路  Source: FriendsOfSymfony/FOSRestBundle

The Symfony routing prevents the "parent" attribute from being set through validation and an exception is thrown.

Bug

Most helpful comment

It seems, that you're trying to load restful route inside default routing configuration. In order to be able to use parent and other rest-specific parameters - you need to move such configs into restful collection.

This is wrong:

# app/config/routing.yml
users:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UsersController

user_topics:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UserTopicsController
  parent:   users

But this is correct:

# app/config/routing.yml
users:
  type: rest
  resource: path/to/your/bundle/routing.yml
# path/to/your/bundle/routing.yml
users:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UsersController

user_topics:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UserTopicsController
  parent:   users

All 3 comments

Can you give me an example here?

It seems, that you're trying to load restful route inside default routing configuration. In order to be able to use parent and other rest-specific parameters - you need to move such configs into restful collection.

This is wrong:

# app/config/routing.yml
users:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UsersController

user_topics:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UserTopicsController
  parent:   users

But this is correct:

# app/config/routing.yml
users:
  type: rest
  resource: path/to/your/bundle/routing.yml
# path/to/your/bundle/routing.yml
users:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UsersController

user_topics:
  type:     rest
  resource: FOS\RestBundle\Tests\Fixtures\Controller\UserTopicsController
  parent:   users

note that you can also load the main file with the type rest by defining the type in your router configuration

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dkorsak picture dkorsak  路  5Comments

MissbachMichael picture MissbachMichael  路  7Comments

maxbeckers picture maxbeckers  路  4Comments

Amunak picture Amunak  路  6Comments

MaksSlesarenko picture MaksSlesarenko  路  4Comments