diff options
author | Evan Prodromou <evan@status.net> | 2010-03-23 12:33:41 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-03-23 12:33:41 -0400 |
commit | dd115fcb080bbd06ccefdd091604574945b6ec54 (patch) | |
tree | c6ae2663b7b59168d35aa8334138fd5db2e6dd64 /lib/router.php | |
parent | ff60cb4e6692558581f6588524eafbfa903b66a9 (diff) |
change router to allow hooking path connections
Diffstat (limited to 'lib/router.php')
-rw-r--r-- | lib/router.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/router.php b/lib/router.php index a48ee875e..a9d07276f 100644 --- a/lib/router.php +++ b/lib/router.php @@ -33,6 +33,33 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { require_once 'Net/URL/Mapper.php'; +class StatusNet_URL_Mapper extends Net_URL_Mapper { + + private static $_singleton = null; + + private function __construct() + { + } + + public static function getInstance($id = '__default__') + { + if (empty(self::$_singleton)) { + self::$_singleton = new StatusNet_URL_Mapper(); + } + return self::$_singleton; + } + + public function connect($path, $defaults = array(), $rules = array()) + { + $result = null; + if (Event::handle('StartConnectPath', array(&$path, &$defaults, &$rules, &$result))) { + $result = parent::connect($path, $defaults, $rules); + Event::handle('EndConnectPath', array($path, $defaults, $rules, $result)); + } + return $result; + } +} + /** * URL Router * @@ -69,7 +96,7 @@ class Router function initialize() { - $m = Net_URL_Mapper::getInstance(); + $m = StatusNet_URL_Mapper::getInstance(); if (Event::handle('StartInitializeRouter', array(&$m))) { |