Re: Bug in the Controller::urlTo method

KevBurnsJr | 3 years ago | parent

I can tell you how I think it should behave...

Routes ought to be evaluated from first to last searching for an appropriate match given the number of variables passed to urlTo.

Currently the router assumes one route per method, so making this change would probably have some fairly far-reaching consequences. For the time being, I suggest working around it by creating a new method as a wrapper for post()

/**
* !Route GET, post/
**/
function postIndex() {
return $this->post();
}

/**
* !Route GET, post/$id/
**/
function post($id = 0) {}


Some other things I would like to see...

Named routes

/**
* !Route GET, post/, postIndex
* !Route GET, post/$id/
**/

to allow for calls like Url::to('postIndex')

Alternative syntax for passing variables to routes as parameters

$controller->urlTo("details?id=43")

It feels cleaner to me. I think I picked it up from Rails. I implemented this on my fork, but it's ignoring the key (id)





Welcome KrisJordan!

Web: http://www.krisjordan.com/

Location: North Carolina

Edit Profile