Allow Web application router to return controller output. #1826

Merged
merged 2 commits into from Mar 27, 2013

3 participants

@piotr-cz

Since new generic Router has a functionality of a dispatcher (executing controllers), it's handy to pass controller output further to caller (Application), especially when it's JApplicationWeb. It's easy to to override this method in own JApplication instance, but IMHO this gives a hint how to use new MVC.

@piotr-cz piotr-cz Allow router to return controller output.
Since new generic Router has a functionality of a dispatcher (executing controllers), it's handy to pass controller output further to callee (Application), especially when it's JApplicationWeb. It's easy to to override this method in own JApplication instance, but IMHO this gives a hint how to use new MVC.
2b09a72
@piotr-cz

Maybe it will become clearer 'why' when I attach a chunk of simple application.
If I'm doing it completely wrong, please let me know but at the moment I really think it's quite convenient when JApplicationWebRouter returns controller output.


protected function doExecute()
{
    // Initialise the application
    $this->initialise();

    // Dispatch the application
    $this->route();
}

public function route()
{
    // Initialise variables
    $document   = $this->getDocument();
    $router     = $this->getRouter();

    // Execute the task.
    try
    {
        $contents   = $router->execute( $this->get('uri.route') );
    }
    // Mop up any uncaught exceptions.
    catch (RuntimeException $e)
    {
        echo $e->getMessage();
        $this->close($e->getCode());
    }

    $document->setBuffer($contents, 'component');
}
@dongilbert

I'm not sure on this one way or the other. Love to have @eddieajau's take on it. I know the new MVC works currently without this, but I could see it as being advantageous, based on how you approach your application architecture.

@eddieajau

I think this is fine if you change the docblock to @return mixed The return value of the controller executed. I wouldn't want to restrict it to 'output'. That is just one possibly scenario. It could also return another controller in an HMVC setting I would imagine.

@eddieajau eddieajau merged commit e1c265e into joomla:staging Mar 27, 2013
@piotr-cz piotr-cz deleted the unknown repository branch Mar 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment