Routing and model syntax #389

Closed
Soullivaneuh opened this Issue Mar 7, 2013 · 4 comments

Projects

None yet

2 participants

@Soullivaneuh

I have a problem with auto-generated routes with the News model.

My routing.yml:

news:
    type:         rest
    resource:     "@NexyAPIBundle/Controller/NewsController.php"
    name_prefix:  nexy_api_

My controller:

<?php

namespace Nexy\APIBundle\Controller;

use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Routing\ClassResourceInterface;

/**
 * Description of NewsController
 *
 * @author sullivan
 */
class NewsController extends FOSRestController implements ClassResourceInterface
{
    public function cgetAction()
    {
        $news = $this->getDoctrine()->getRepository('NexyMainBundle:News')->findAll();

        $view = $this->view($news, 200);

        return $this->handleView($view);
    }

    public function getAction($id)
    {
        $news = $this->getDoctrine()->getRepository('NexyMainBundle:News')->find($id);

        $view = $this->view($news, 200);

        return $this->handleView($view);
    }
}

?>

And when I run php app/console router:debug | grep api:

nexy_api_get_news                                  GET      /api/news/{id}.{_format}

This error is cause by the name of the model News, I should have this I think:

nexy_api_get_newses                               GET      /api/newses.{_format}
nexy_api_get_news                                  GET      /api/news/{id}.{_format}

How can I solve this issue ?

Thanks.

@Soullivaneuh

Ok my english is not perfect, news does not have singular form.

So I have to edit this class and add it to uncountables property ?

@lsmith77
Member
lsmith77 commented Mar 7, 2013

yeah ..

@lsmith77
Member

this now even configurable

@lsmith77 lsmith77 closed this Aug 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment