Skip to content
This repository

Resource Pluralization as an option. #294

Open
stephpy opened this Issue September 06, 2012 · 7 comments

4 participants

Stéphane PY mevers47 Lukas Kahwe Smith Tarjei Huse
Stéphane PY

Hi,

Actually, routing use pluralization automatically for resources. What do you think about an option to be able to deactivate that ? For sure, by default it'll be activated ...

It could be defined on config:

fos_rest:
   resource:
       pluralize_path: true

And even on RouteResource annotation ?

/**
*@RouteResource("User", false) 
*/
mevers47

+1 Can be very handy in my situation where every resource has one name, not a plural and singular one. Just one singular name, like the name for an entity.

Lukas Kahwe Smith
Owner

i think if at all pluralization needs to be disabled only on the resource level, since otherwise it can cause incompatibilities between Bundles expecting the option to be on or off.

Tarjei Huse

@lsmith77 could you provide pointers to how this should be implemented as part of the RouteResource annotation?

Lukas Kahwe Smith
Owner
Tarjei Huse

Ok, I tried that. I got quite far, but my unittests fail with the error:

Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected Value, got 'r' at position 31 in class FOS\RestBundle\Tests\Fixtures\Controller\AnnotatedNonPlurlizedArticleController.

Here's the value I tried:

/**
 *  @Rest\RouteResource("Article", false)
 */
class AnnotatedNonPlurlizedArticleController extends FosRestController

And the Annotation definition:

/**
 * RouteResource annotation class.
 * @Annotation
 * @Target("CLASS")
 */
class RouteResource
{
    /**
     * @var string required
     */
    public $resource;

    /**
     * @var boolean
     */
    public $pluralize = false;


}
Lukas Kahwe Smith
Owner

can you just open a PR with your work? makes reviewing easier.

Tarjei Huse

I'll do that tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.