Question

I execute following class from my dispatcher class but neither class_exists nor call_user_func execute the class, the __controller never runs. The session doesn't start. At the moment as work around I am adding $i = new Admin(); before the class deceleration so the class get's activated when the page is loaded. But this behavior seam odd to me.

Extract from dispatcher class:

        include $this->file;

        if (class_exists($this->controller, TRUE)) {

            if (!is_callable($this->controller, $this->action)) {
                header('Location: /404.php');
                exit;
            }
            call_user_func(array ($this->controller, $this->action), $this->route->values);
        }



<?php
class Admin
{

    public function __construct()
    {
        S::V()->title()->set('Admin');

        if (!isset($_SESSION))
            session_start();
        if (!isset($_SESSION['auth']))
            header('Location: /cp/login');      
    }

    public function lobby($args)
    {
        S::V()->title()->append(' Logger');
        if (isset($_REQUEST['clear'])) {
            S::L()->clear();
        }

        $data['raw'] = S::Logger()->gethtml('20');
        S::V()->addData($data);
        echo S::V()->fetch('admin.php', $data);
    }
?>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top