/** * call an action file. * this shouldn't produce any output. * by convention, it should return some sort of data, usually an array * that can be consumed by the view * this is mapped into the view container. * if strict, trigger errors if the path isn't found. */ public function execute($name, $strict = TRUE) { $path = \Wukka\ShortCircuit::resolver()->get($name, 'action'); if (!$path) { if ($strict) { trigger_error('invalid action: ' . $name, E_USER_WARNING); } return; } return include $path; }
/** * alias method for the router server object. */ public function resolver() { return \Wukka\ShortCircuit::resolver(); }
<?php include __DIR__ . '/../../autoload.php'; use Wukka\ShortCircuit; use Wukka\ShortCircuit\Resolver; use Wukka\ShortCircuit\PatternResolver; $patterns = array('/go/(id)/' => 'nested/test', '/foo/bar/(a)/test/(b)' => 'nested/deep/test', '/idtest/(id)/' => 'id', '/lt/(a)/(b)/(c)' => 'linktest'); ShortCircuit::resolver(new Resolver(__DIR__ . '/../app/', $patterns)); ShortCircuit::run();