From 8cd84376b5f9f90f8e6741f9358f44718d85b710 Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 3 Jun 2016 18:17:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=BE=D1=83=D1=82=D0=B8=D0=BD=D0=B3=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config/hubConfig.class.php | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) 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.