Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect::to(...) in App:before Filter causes Error (L4.0) #18

Closed
wegnermedia opened this issue Dec 3, 2013 · 1 comment
Closed

Redirect::to(...) in App:before Filter causes Error (L4.0) #18

wegnermedia opened this issue Dec 3, 2013 · 1 comment

Comments

@wegnermedia
Copy link

Hi,

I use my App::before Filter to check if the first segment of the requested URL is an available locale (e.g en or de) if it's not, it Redirects to a default -> because there is no Route set for this.

When i redirect it throws an error, on line 183 of LaravelDataSource.php (calling getAction() on a non Object)

here is my little fix:

protected function getController()
{
$router = $this->app['router'];

if (method_exists($router, 'getCurrentRoute')) { // Laravel 4.0
    // $controller = $router->getCurrentRoute()->getAction();
    $current = $router->getCurrentRoute();
    $controller = (is_null($current)) ? null : $current->getAction();
} else { // Laravel 4.1
    $controller = $router->current()->getActionName();
}
if(!is_null($controller))
{
    if ($controller instanceof Closure) {
        $controller = 'anonymous function';
    } else if (is_object($controller)) {
        $controller = 'instance of ' . get_class($controller);
    } else if (is_array($controller) && count($controller) == 2) {
        if (is_object($controller[0]))
            $controller = get_class($controller[0]) . '->' . $controller[1];
        else
            $controller = $controller[0] . '::' . $controller[1];
    } else if (!is_string($controller)) {
        $controller = null;
    }
}   
return $controller;

}

Greetings :-)

@itsgoingd
Copy link
Owner

Hey, fixed in dev-master, thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants