Ejemplo n.º 1
0
 public function actionModule($module, $controller = 'Admin', $action = Router::DEFAULT_ACTION)
 {
     try {
         $this->app->runRoute(new Route('/' . ucfirst($module) . '/' . ucfirst($controller) . '/' . ucfirst($action)), Router::getInstance()->getFormatByExtension($this->app->request->extension));
         exit;
     } catch (Exception $e) {
         throw new E404Exception('Ошибка админ-панели в модуле ' . $module . ': ' . $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 public function getAllTemplates()
 {
     $route = Router::getInstance()->splitInternalPath($this->path);
     $controller = Application::getInstance()->createController($route->module, $route->controller);
     $templates = [];
     foreach ($controller->getTemplatePaths() as $path) {
         foreach (glob($path . DS . $route->action . '.*.block.html') as $filename) {
             preg_match('~.*\\.([^\\.]+)\\.block\\.html~', basename($filename), $m);
             $templates[] = $m[1];
         }
     }
     return $templates;
 }
Ejemplo n.º 3
0
 public function testParseUrl()
 {
     $router = \T4\Mvc\Router::getInstance();
     $reflector = new ReflectionMethod($router, 'parseRequestPath');
     $reflector->setAccessible(true);
     $router->setConfig(getLambdaRouteConfig());
     $url = '/';
     $this->assertEquals(new \T4\Mvc\Route(['module' => '', 'controller' => 'Index', 'action' => 'Default', 'params' => [], 'format' => 'html']), $reflector->invoke($router, $url));
     $url = '/goods';
     $this->assertEquals(new \T4\Mvc\Route(['module' => 'Shop', 'controller' => 'Goods', 'action' => 'Default', 'params' => [], 'format' => 'html']), $reflector->invoke($router, $url));
     $url = '/goods/13.html';
     $this->assertEquals(new \T4\Mvc\Route(['module' => 'Shop', 'controller' => 'Goods', 'action' => 'View', 'params' => ['id' => 13], 'format' => 'html']), $reflector->invoke($router, $url));
     $url = '/shop/volvo/42.html';
     $this->assertEquals(new \T4\Mvc\Route(['module' => 'Shop', 'controller' => 'Goods', 'action' => 'View', 'params' => ['id' => '42', 'vendor' => 'volvo'], 'format' => 'html']), $reflector->invoke($router, $url));
     $url = 'auto.fr!/shop/volvo/42.html';
     $this->assertEquals(new \T4\Mvc\Route(['module' => 'Shop', 'controller' => 'Goods', 'action' => 'View', 'params' => ['lang' => 'fr', 'id' => '42', 'vendor' => 'volvo'], 'format' => 'html']), $reflector->invoke($router, $url));
 }
Ejemplo n.º 4
0
 /**
  * @param \T4\Http\Request $request
  */
 protected function runRequest(Request $request)
 {
     $route = Router::getInstance()->setConfig($this->config->routes)->parseRequest($request);
     $this->runRoute($route, $route->format);
 }