示例#1
0
 public static function defaultClientLanguage()
 {
     $lang = \Novosga\Util\I18n::locale();
     return current(explode('_', $lang));
 }
示例#2
0
文件: index.php 项目: charlyR/novosga
         $app->moduleResource($moduleKey, join(DS, array_slice($args, 1)));
     } catch (Exception $e) {
         $app->notFound();
     }
 }
 $namespace = MODULES_DIR . '\\' . $tokens[0] . '\\' . $tokens[1];
 $ctrlClassPrefix = $tokens[1];
 // buscando modulo a partir do banco
 $module = $app->getContext()->getModulo();
 // nome do controlador
 $ctrlClass = ucfirst($ctrlClassPrefix) . 'Controller';
 $ctrlClass = '\\' . $namespace . '\\' . $ctrlClass;
 $ctrl = new $ctrlClass($app, $module);
 $moduleDir = MODULES_PATH . "/{$tokens[0]}/{$tokens[1]}";
 // module locale
 \Novosga\Util\I18n::bindDomain($moduleKey, "{$moduleDir}/locales");
 // module views
 $app->view()->twigTemplateDirs = array(NOVOSGA_TEMPLATES, "{$moduleDir}/views");
 $app->view()->set('module', $module);
 // controller action
 $methodName = str_replace('/', '_', str_replace('-', '_', $action));
 $method = new \ReflectionMethod($ctrl, $methodName);
 $response = $method->invokeArgs($ctrl, $args);
 if ($response instanceof \Novosga\Http\JsonResponse) {
     $app->response()->header('Content-type', 'application/json');
     $app->response()->write($response->toJson());
 } else {
     // render as template the returned template name or action name pattern
     if (is_string($response)) {
         $template = $response;
     } else {