FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 703 forks source link

parent/child resource error: Every parent controller must have `get{SINGULAR}Action($id)` method #1185

Closed pstephenson02 closed 4 years ago

pstephenson02 commented 8 years ago

In this gist, I have 3 controllers defined. I want to establish a parent/child relationship between the cah_annotation and the standard_proposal resource. I cannot find the reason for this error:

$ ./app/console debug:router

  [Symfony\Component\Config\Exception\FileLoaderLoadException]                                                    
  Every parent controller must have `get{SINGULAR}Action($id)` method                                             
  where {SINGULAR} is a singular form of associated object in /var/www/html/cdpaccess/src/ICC/ProposalBundle/Res  
  ources/config/routing.yml (which is being imported from "/var/www/html/cdpaccess/app/config/routing.yml").      

  [InvalidArgumentException]                                           
  Every parent controller must have `get{SINGULAR}Action($id)` method  
  where {SINGULAR} is a singular form of associated object             

The weird thing is, if I modify routing.yml and set the parent resource on cah_annotation to proposal:

cah_annotation:
    parent: proposal

It works fine. Even if I delete the proposal resource entry all together I get the same error.

What am I doing wrong here? These controllers are very similar, how is it that it works with the proposal resource but not standard_proposal?

$ php composer.phar show -i | grep rest
friendsofsymfony/rest-bundle               1.7.2                 This Bundle provides various tools to rapidly...
xabbuh commented 8 years ago

Can you check #1173?

pstephenson02 commented 8 years ago

I did first check https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1173 and its associated stackoverflow question.

I made sure that was not the issue here. The method parameters are defined correctly (or rather: are not incorrect in the way they were shown in the stack question)

xabbuh commented 8 years ago

@pstephenson02 Instead of getStandardProposalAction() try getAction() instead.

xabbuh commented 8 years ago

Though I think the error message should indeed be improved.

Tobion commented 4 years ago

Closing as automatic route generation is deprecated: #1954