Example #1
0
 public function __construct()
 {
     /**
      * @var $configuration Configuration
      */
     $configuration = Application::get_class(Configuration::class);
     $pages = $configuration->pages;
     $area_routers = $configuration->routers;
     switch (array_replace_recursive([''], Request::uri_parts())[0]) {
         case 'admin_panel':
             $this->routes = $pages['admin_panel'];
             $this->area_router = Application::get_class($area_routers['admin_panel']);
             break;
         case 'rest':
             $routes = array_merge($pages['site'], $pages['admin_panel']);
             /**
              * mix site and admin panel routes with other rest routes to not duplicate url's
              */
             $routes = array_merge(array_combine(array_map(function ($el) {
                 return '/rest/templates' . $el;
             }, array_keys($routes)), $routes), $pages['rest']);
             $this->routes = $routes;
             $this->area_router = Application::get_class($area_routers['rest']);
             break;
         case 'action':
             $this->routes = $pages['action'];
             $this->area_router = Application::get_class($area_routers['action']);
             break;
         default:
             $this->routes = $pages['site'];
             $this->area_router = Application::get_class($area_routers['site']);
     }
 }
Example #2
0
 /**
  * @covers common\classes\Request::uri_parts
  */
 public function test_uri_parts()
 {
     $_SERVER['REQUEST_URI'] = '/test.com/test1?asd=dsa';
     self::assertEquals(['test.com', 'test1'], Request::uri_parts());
 }