Resource Pluralization as an option. #294

Closed
stephpy opened this Issue Sep 6, 2012 · 9 comments

Comments

Projects
None yet
5 participants
@stephpy
Contributor

stephpy commented Sep 6, 2012

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

This comment has been minimized.

Show comment Hide comment
@mevers47

mevers47 Sep 13, 2012

+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.

+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.

@lsmith77

This comment has been minimized.

Show comment Hide comment
@lsmith77

lsmith77 Sep 23, 2012

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.

Owner

lsmith77 commented Sep 23, 2012

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

This comment has been minimized.

Show comment Hide comment
@tarjei

tarjei Aug 16, 2013

Contributor

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

Contributor

tarjei commented Aug 16, 2013

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

@lsmith77

This comment has been minimized.

Show comment Hide comment
@lsmith77

lsmith77 Aug 16, 2013

Owner

look at the annotation class and add another property. this will result in having another attribute to set in the annotation

Owner

lsmith77 commented Aug 16, 2013

look at the annotation class and add another property. this will result in having another attribute to set in the annotation

@tarjei

This comment has been minimized.

Show comment Hide comment
@tarjei

tarjei Aug 16, 2013

Contributor

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;


}
Contributor

tarjei commented Aug 16, 2013

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;


}
@lsmith77

This comment has been minimized.

Show comment Hide comment
@lsmith77

lsmith77 Aug 18, 2013

Owner

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

Owner

lsmith77 commented Aug 18, 2013

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

@tarjei

This comment has been minimized.

Show comment Hide comment
@tarjei

tarjei Aug 19, 2013

Contributor

I'll do that tomorrow.

Contributor

tarjei commented Aug 19, 2013

I'll do that tomorrow.

@lsmith77 lsmith77 added this to the 2.0 milestone Jul 10, 2015

@GuilhemN

This comment has been minimized.

Show comment Hide comment
@GuilhemN

GuilhemN Aug 17, 2015

Member

This issue/PR seems to be abandoned ... I will continue this work in a new PR.

Member

GuilhemN commented Aug 17, 2015

This issue/PR seems to be abandoned ... I will continue this work in a new PR.

@lsmith77

This comment has been minimized.

Show comment Hide comment
@lsmith77

lsmith77 Aug 30, 2015

Owner

closed via #1096

Owner

lsmith77 commented Aug 30, 2015

closed via #1096

@lsmith77 lsmith77 closed this Aug 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment