array( 'url_manager' => 'Application.Web.Class.WebUrlMapping', 'url_pattern' => '!^/web/!', 'endpoints' => 'Application.Web.endpoints' ), 'api' => array( 'url_manager' => 'Application.API.Class.APIUrlMapping', 'url_pattern' => '!^/api/!', 'endpoints' => 'Application.API.endpoints' ) ); public function __construct() { parent::__construct(); $this->setServiceUrlManager(); } private function getServiceID() { $service_id = null; $url = $this->getRequestedUrl(); foreach ($this->services as $id => $params) { if (preg_match($params['url_pattern'], $url) === 1) { $service_id = $id; break; } } return $service_id; } private function setServiceUrlManager() { $service_id = $this->getServiceID(); if (array_key_exists($service_id, $this->services)) { $service = $this->services[$service_id]; $path = Prado::getPathOfNamespace($service['url_manager'], Prado::CLASS_FILE_EXT); if (file_exists($path)) { $this->setDefaultMappingClass($service['url_manager']); $this->setConfigFile($service['endpoints']); } } } private function getRequestedUrl() { $url = $this->getRequest()->getPathInfo(); return $url; } } ?>