protected function initUri($source) { $map = self::$uri_map; $gadgets = SiteGadgetFactory::getAvailable($this->app); foreach ($gadgets as $gadget) { $map = array_merge($map, $gadget->ajax_proxy_map); } foreach ($map as $from => $to) { // escape delimiters $pattern = str_replace('@', '\\@', $from); $regexp = '@' . $pattern . '@u'; if (preg_match($regexp, $source) === 1) { // replace matches in to string $this->uri = preg_replace($regexp, $to, $source); break; } } if ($this->uri === null) { throw new SiteNotFoundException('Page not found.'); } }