diff --git a/lib/config/hubConfig.class.php b/lib/config/hubConfig.class.php index ac2669f..267c9d6 100644 --- a/lib/config/hubConfig.class.php +++ b/lib/config/hubConfig.class.php @@ -3,6 +3,8 @@ class hubConfig extends waAppConfig { + protected $_routes; + public function onInit() { $wa = wa(); @@ -12,6 +14,41 @@ public function onInit() $this->maybeArchiveTopics(); } } + + public function getRouting($route = array(), $dispatch = true) + { + if ($this->_routes === null || $dispatch) { + $routes = parent::getRouting($route); + /** + * Extend routing via plugin routes + * @event routing + * @param array $routes + * @return array routes collected for every plugin + */ + $result = wa()->event(array($this->application, 'routing'), $routes); + $all_plugins_routes = array(); + foreach ($result as $plugin_id => $routing_rules) { + if ($routing_rules) { + $plugin = str_replace('-plugin', '', $plugin_id); + foreach ($routing_rules as $url => &$route) { + if (!is_array($route)) { + list($route_ar['module'], $route_ar['action']) = explode('/', $route); + $route = $route_ar; + } + $route['plugin'] = $plugin; + $all_plugins_routes[$url] = $route; + } + unset($route); + } + } + $routes = array_merge($all_plugins_routes, $routes); + if ($dispatch) { + return $routes; + } + $this->_routes = $routes; + } + return $this->_routes; + } /** * Return timestamp of last user activity in previous user session.