예제 #1
0
if (in_array($action, $courseactions)) {
    require_login($course, false, $cm, false, true);
} else {
    require_login();
}
/** @var $PAGE moodle_page */
$PAGE->set_context($context);
$PAGE->set_url('/theme/snap/rest.php', array('action' => $action, 'contextid' => $context->id));
$router = new router();
// Add controllers automatically.
$controllerdir = __DIR__ . '/classes/controller';
$contfiles = scandir($controllerdir);
foreach ($contfiles as $contfile) {
    if ($contfile === 'addsection_controller.php') {
        continue;
    }
    $pattern = '/_controller.php$/i';
    if (preg_match($pattern, $contfile) !== 1) {
        continue;
    } else {
        $classname = '\\theme_snap\\controller\\' . str_ireplace('.php', '', $contfile);
        if (class_exists($classname)) {
            $rc = new ReflectionClass($classname);
            if ($rc->isSubclassOf('\\theme_snap\\controller\\controller_abstract')) {
                $router->add_controller(new $classname());
            }
        }
    }
}
$kernel = new kernel($router);
$kernel->handle($action);
예제 #2
0
 /**
  * @expectedException \coding_exception
  */
 public function test_execute_callback_with_both()
 {
     $kernel = new kernel(new router());
     $kernel->execute_callback(array($this, '_both_string_callback'));
 }