Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

getting a urlTo another controller's method should be much more concise, like so...

#70

Already can call $this->urlTo('methodName'), but to get the path for a method of another class requires instantiating it and using urlTo on the new instance. It's verbose, it takes at least to lines, and it obscures what you're actually trying to do. This would be so much nicer:

$this->urlTo('FooController::bar');

And it can be implemented something like this (Added at the beginning of urlTo):

if(strpos('::',$methodName)!==false) { list($controllerName,$methodName) = explode('::',$methodName,2); $controller = new $controllerName($this->application); return $controller->urlTo($methodName); }

You still have to Library::import the relevant class beforehand, but I'm ok with that, personally.

Reported by Joshua Paine · February 13th, 2009 @ 11:00 PM

State: resolved
Milestone: 0.11.1
Assigned to: Kris Jordan Kris Jordan

Activity

  1. Joshua Paine
    Joshua Paine

    ick--just noticed what lighthouse did to my code. But more importantly, the args of strpos are reversed. Let's try this again:

    if(strpos($methodName,'::')!==false) {
        list($controllerName,$methodName) = explode('::',$methodName,2);
        $controller = new $controllerName($this->application);
        return $controller->urlTo($methodName);
    }
    
    

    February 14th, 2009 @ 05:31 PM

  2. Kris Jordan
    Kris Jordan
    • Milestone set to 0.11.1
    • State changed from new to resolved

    Thanks for the submission - great improvement in the API!

    This has been added to the source tree with commit 2c3b1a0.

    February 16th, 2009 @ 02:48 PM

  3. joazito
    joazito

    In order for this to work with arguments I needed to replace this line:

    return $controller->urlTo($methodName);

    With this below:

    return call_user_func_array(array($controller, 'urlTo'), array_merge(array($methodName), $args));

    May 16th, 2009 @ 11:35 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.