Controller::__construct PHP Method

__construct() public method

Construct the (base) controller. This happens when a real controller is constructed, like in the constructor of IndexController when it says: parent::__construct();
public __construct ( )
    public function __construct()
    {
        // always initialize a session
        Session::init();
        // check session concurrency
        Auth::checkSessionConcurrency();
        // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
        if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
            header('location: ' . Config::get('URL') . 'login/loginWithCookie');
        }
        // create a view object to be able to use it inside a controller, like $this->View->render();
        $this->View = new View();
    }

Usage Example

 function __construct()
 {
     global $basePath;
     $respons = array();
     parent::__construct();
     $parts = $this->getUrlParts();
     $this->startSession();
     $this->auth($parts[3]);
     if ($parts[4] === "schema") {
         $dir = $basePath . "tmp/" . $parts[3] . "/" . $parts[5] . ".*";
         //echo $dir;
     } else {
         $dir = $basePath . "tmp/" . $parts[3] . "/" . $parts[4];
     }
     $dir = str_replace("..", "", $dir);
     //$dirReal = realpath($dir); // Do not work on *
     if ($dir) {
         exec("rm -R {$dir}");
         $respons['success'] = true;
         $respons['message'] = "Tile cache invalidated";
     } else {
         $respons['success'] = false;
         $respons['message'] = "No tile cache to invalidate.";
     }
     echo $this->toJSON($respons);
 }
All Usage Examples Of Controller::__construct
Controller