addDispatcher() public static method

addDispatcher add new Dispatcher
public static addDispatcher ( Pix_Controller_Dispatcher | callable $dispatcher ) : void
$dispatcher Pix_Controller_Dispatcher | callable
return void
Ejemplo n.º 1
0
<?php

include __DIR__ . '/init.php';
Pix_Controller::addDispatcher(function ($url) {
    list(, $contoller, $action) = explode('/', $url, 3);
    switch ($contoller) {
        case 'board':
            return array('index', 'board');
    }
    return null;
});
Pix_Controller::dispatch(__DIR__ . '/webdata');
Ejemplo n.º 2
0
<?php

include __DIR__ . '/webdata/init.inc.php';
class MyDispatcher extends Pix_Controller_Dispatcher
{
    public function dispatch($path)
    {
        if (preg_match('#^/id/\\d+$#', $path)) {
            return array('index', 'show');
        } elseif (preg_match('#^/fund/#', $path)) {
            return array('index', 'fund');
        } elseif (preg_match('#^/name/#', $path)) {
            return array('index', 'name');
        }
        return null;
    }
}
Pix_Controller::addDispatcher(new MyDispatcher());
Pix_Controller::addCommonHelpers();
Pix_Controller::dispatch(__DIR__ . '/webdata/');