GithubHelp home page GithubHelp logo

ErrorController redeclaration about huge HOT 2 OPEN

elbenjaz avatar elbenjaz commented on June 25, 2024 2
ErrorController redeclaration

from huge.

Comments (2)

losttheplot avatar losttheplot commented on June 25, 2024 2

I'm using huge at the core of quite a large project but I don't have this issue because I have created a method within Redirect.php as follows:

    //----------------------------------------------------------------------------------------------
    // redirect the user to a 404 page, according to whether or not they are logged in
    //----------------------------------------------------------------------------------------------
    public static function error404()
    {
        if (Session::userIsLoggedIn()) {
            
            // if the user is logged in, load the application's 404 page (shows header-bar and side-menu)
            $config = Config::getInstance();
            require $config->getApp('path_controller').'access/ErrorController.php';
            $controller = new ErrorController;
            $controller->error404();
            
        } else {
            
            // if the user is not logged in, load the application's plain 404 page (only shows dialogue box)
            $config = Config::getInstance();
            require $config->getApp('path_controller').'access/ErrorController.php';
            $controller = new ErrorController;
            $controller->loggedOut404();
            exit();
        }
    }

...and then in Application.php I have...

            } else {
                // show a 404 error page if the requested method does not exist
                Redirect::error404();
            }
        } else {
            // show a 404 error page if the requested controller does not exist
            Redirect::error404();
        }
    }

Obviously my Error Controller also looks a little different because it now has two different methods for rendering two different views, but I'm sure you get the gist.

from huge.

elbenjaz avatar elbenjaz commented on June 25, 2024

Hi,

I also tried that!

(before)
require_once Config::get('PATH_CONTROLLER') . 'ErrorController.php'; $this->controller = new ErrorController; $this->controller->error404();

(after)
Redirect::to("error/error404");
Personally I prefer not to do a redirect so that the user does not "lose" the URL (similar to what Google, Amazon and many others do).

Regardless, both changes should be a reasonable solution to the issue :)

from huge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.