Welcome Guest, Not a member yet? Register   Sign In
Custom resource controller routing
#1

(This post was last modified: 03-14-2016, 09:25 PM by albertleao.)

I understand there is going to be resource controller routing in CI4. While this is exciting, one thing I have always found annoying when working with resources in other frameworks (RoR, Laravel, Phoenix) is that you can't really tell the framework what your default resources are and what they are called.

I have a project where I have my usual :: index, :: show, :: edit, :: create, :: store, :: update, :: destroy methods for every controller, so I use a resource in my routes to get there, but I also have a ::trash method in every controller which I must add to every single controller in my route file.

Not sure how great of a suggestion this is but I would love for there to be a place in some config file where I could set what the default resource routes are.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#2

There's currently a way to limit the routes generated by the resources command. There's nothing yet for adding additional ones, but it's a good feature, i think. I'll take a think on it and see the best way to do it.

My gut instinct says a new method that adds additional routes and mapping to all resourceful routes generated after that. Would something like that work?
Reply
#3

(03-14-2016, 09:34 PM)kilishan Wrote: There's currently a way to limit the routes generated by the resources command. There's nothing yet for adding additional ones, but it's a good feature, i think. I'll take a think on it and see the best way to do it.

My gut instinct says a new method that adds additional routes and mapping to all resourceful routes generated after that. Would something like that work?

I'm not sure. I've only glimpsed through the CI4 code as it is right now so I don't have a good feel of how it would/should be implemented. At the end of the day, allowing the dev to customize the default route names seems like a good idea to me. Out of habit (and experience from other places), my first function is always called index() not listAll().
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB