Example #1
0
 /**
  * Maps a method to the specified URL. Note that if no class is specified
  * Koi will assume the method is available to the current class ($this).
  * A class can be specified by setting the third argument. Note that when you're
  * using the third argument this should be an object, not a string.
  *
  * @author Yorick Peterse
  * @param string $uri The URI to map the method to.
  * @param string $method The method to call when the $url URL is requested.
  * @param object $class The class to invoke $method on. By default the current class
  * will be used.
  * @return void
  */
 public function map($uri, $method, $class = NULL)
 {
     // Get the default object to call $method on
     if (empty($class) or $class === NULL) {
         $class =& $this;
     }
     if (isset($this->mappings[$uri]) and !empty($this->mappings[$uri])) {
         throw new Exception\MappingException("A method has already been mapped to {$uri}");
     }
     $prep = Router::prepare_uri($uri, $method);
     $uri = $prep[0];
     $method = $prep[1];
     $this->mappings[$uri] = array('method' => $method, 'object' => $class);
 }