Beispiel #1
0
 protected function render($data = array())
 {
     static $view = null;
     $api = \ApiModel::getInstance();
     $module = $api->getModule();
     if (!isset($view)) {
         $view = new SmartyView();
         $view->setScriptPath(APP_PATH . '/views/index/' . strtolower($module));
     }
     $version = $api->getVersion();
     $method = str_replace(array('_', '.'), '/', $api->getMethod());
     $tpl = strtolower(str_replace('.', 'd', $version) . '/' . str_replace('_', '/', $method) . '.phtml');
     return $view->render($tpl, $data);
 }
Beispiel #2
0
 function dispatchLoopStartup(Request_Abstract $request, Response_Abstract $response)
 {
     $dispatcher = Dispatcher::getInstance();
     $controllerName = strtolower($request->getControllerName());
     $isApi = 0 === strpos($controllerName, 'api');
     $isCli = 0 === strpos($controllerName, 'cli_');
     // db
     \Zend_Db_Table::setDefaultAdapter(AbstractModel::getInstance()->getMultiDb()->getDefaultDb());
     // view
     if ($isApi) {
         $dispatcher->disableView();
     } else {
         if ($response instanceof Http) {
             $response->setHeader('Content-Type', 'text/html; charset=UTF-8');
         }
         $dispatcher->setView(SmartyView::getInstance());
     }
     // cli
     if ($isCli && !$request->isCli()) {
         $request->setControllerName('Error')->setActionName('error403');
     }
 }