public function loadRoutes() { $routing = new api_routing(); $route = $routing->getRoute($this->request); // print_r($route); if (is_null($route) || !is_array($route)) { throw new api_exception_NoControllerFound(); } $this->route =& $route; }
/** * Removes all defined routes. */ public function clear() { self::$routes = array(); }
<?php $m = new api_routing(); // Default rule (template) $default = new api_routing_route(); $default->route('/:bucket/+asset')->config(array('view' => array('class' => 'xmlhead', 'xsl' => 'binarypool.xsl'))); // https://wiki.local.ch/display/I3/Delete+binary $m->add($default->dup()->when(array('verb' => 'DELETE'))->config(array('command' => 'delete'))); // https://wiki.local.ch/display/I3/Update+modification+date $m->add($default->dup()->when(array('verb' => 'POST'))->config(array('command' => 'touch'))); // https://wiki.local.ch/display/I3/Get+asset+by+SHA1+hash $cmd = $m->add($default->dup()->when(array('verb' => 'GET'))->route('/:bucket/sha1/:hash')->config(array('command' => 'sha1'))); $m->add($cmd->dup()->when(array('verb' => 'HEAD'))); // https://wiki.local.ch/display/I3/List+buckets $cmd = $m->add($default->dup()->when(array('verb' => 'GET'))->route('/')->config(array('command' => 'buckets'))); $m->add($cmd->dup()->when(array('verb' => 'HEAD'))); // https://wiki.local.ch/display/I3/List+assets+by+creation+date $cmd = $m->add($default->dup()->when(array('verb' => 'GET'))->route('/:bucket/created/:year/:month/:day')->config(array('command' => 'view', 'viewname' => 'created'))); $m->add($cmd->dup()->when(array('verb' => 'HEAD'))); // Assets by expiry date $cmd = $m->add($default->dup()->when(array('verb' => 'GET'))->route('/:bucket/expiry/:year/:month/:day')->config(array('command' => 'view', 'viewname' => 'expiry'))); $m->add($cmd->dup()->when(array('verb' => 'HEAD'))); // Assets downloaded by hash of source URL $cmd = $m->add($default->dup()->when(array('verb' => 'GET'))->route('/:bucket/downloaded/:prefix')->config(array('command' => 'view', 'viewname' => 'downloaded'))); $m->add($cmd->dup()->when(array('verb' => 'HEAD'))); // Assets downloaded by hash of source URL - allow HEAD requests // to test for existance without needing to parse XML $cmd = $m->add($default->dup()->when(array('verb' => 'GET'))->route('/:bucket/downloaded/:prefix/:hash')->config(array('command' => 'view', 'viewname' => 'downloaded'))); $m->add($cmd->dup()->when(array('verb' => 'HEAD'))); // Migration path for binarypool serving $cmd = $m->add($default->dup()->route('/migrate/:stage/priv/:bucket/+asset')->when(array('verb' => 'GET'))->config(array('command' => 'migrationserve', 'area' => 'priv')));