Getting controller variables in a loader view method?
===

I'm building a script that got a static class used to load few things including files and views.

    class load
    {
        public static function view($file_path, $area)
        {
            debug::log('getting view <b>' . $area . $file_path . '</b>.');
            ob_start();
            self::file($file_path, 'areas/' . $area . '/views');
            debug::log('flushing view <b>' . $area . $file_path . '</b>.');
            eturn ob_get_clean();
        }

        public static function file($file, $folder)
        {
            if(is_file($file_path = ROOT . '/' . $folder . '/' . $file)) 
            {
                if(require_once $file_path)
                {
                    debug::log('file <b>' . $file_path . '</b> included.');
                    return true;
                }
            }
            else
                debug::kill('requested file <b>' . $file_path . '</b> does not exist.');
        }	
    }

In the controller Im calling the view method to get a view:

    $html = load::view('public', 'path/to/view/file.php');

Obviously, Im not able to access the variables from the controller at the view file using this practice, so I did a small modification on the view class to capture the vars:

    public static function view($file_path, $area, $vars = array())

And added the following lines of codes to get the keys into vars:

    while(list($n_list_var,$v_list_var)=each($vars))
			$$n_list_var = $v_list_var;

But again I can't access the vars since Im using a method to load a file.

I have a method to load the files because I wanna test and log each file include attempt and not repeat the code every time I need include a file. And I have the loader view inside the loader class so I have all the methods of this kind together. Should I give up on using a class to load files? Should I use the loader view method on a extendable class from my controller?

Instead of going ahead and modify my entire script I would like to hear some opinions ... what would be the best practice to go? Or is there a way to solve my problem? Maybe using __set and __get magic methods?

Thanks,