Coder Social home page Coder Social logo

Comments (4)

trandangtri avatar trandangtri commented on June 26, 2024

IMO, I think we should separate 2 cleaned parts:

  • GET, POST, PUT, DELETE will be handled by RestController
  • All the others (with '_' prefix, _all, _batch for instance) which I called commands, will be handled by CommandController. It's very easy to implement new commands

You could take a look on my work (still be in progress)
trandangtri@a9e214b#diff-47c6f7be84a1fcdde5ffc18ec6958135R20

What do you think about this, @saimaz?

from apibundle.

saimaz avatar saimaz commented on June 26, 2024

I'll take a look tomorrow.

As of two parts. CommandController is not very accurate name for _batch and _all. I know that it might be more some same routes, but it should be named something like ColelctionController or the other way is create separate controller for batch and for all, then it will make more sense. Even if we will add some other not traditional route, it will be clean way to do it with separate controller. Also imagine if there will be needed to add some additional parameters to both controllers, then it will become more complex. So I vote for separate controller for each action _batch and _all.

Maybe @mvar has some thoughts and advises?

from apibundle.

mvar avatar mvar commented on June 26, 2024

Sorry, no suggestions. I just don't like the name command. Besides that everything sounds good. I like the idea to separate REST from non-REST.

from apibundle.

trandangtri avatar trandangtri commented on June 26, 2024

Thanks @mvar. I changed Command to Collection.

And I added a mapping configuration into the Abstract Collection class, so you could define yours commands in an individual class or separated classed.

/**
     * Mapping of the commands
     *
     * @var array
     */
    private $mapping = [
        '_all' => [
            '_controller' => 'ONGRApiBundle:Collection:all',
            'methods' => ['GET'],
            'validator' => 'allow_get_all'
        ],
        '_batch' => [
            '_controller' => 'ONGRApiBundle:Collection:batch',
            'methods' => ['POST'],
            'validator' => 'allow_batch'
        ]
    ];

from apibundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.