Exemplo n.º 1
0
 /**
  * Routes the request to appropriate controller and returns resource params
  *
  * @return Resource $resource
  */
 public static function getResource()
 {
     $resource = new Resource();
     $firstParam = RequestManager::getParam(RequestManager::FIRST_PARAM);
     $secondParam = RequestManager::getParam(RequestManager::SECOND_PARAM);
     $thirdParam = RequestManager::getParam(RequestManager::THIRD_PARAM);
     if (AuthController::isLoggedIn()) {
         if (empty($firstParam) && empty($secondParam) && empty($thirdParam)) {
             $resource->setKey(Constants::INDEX_URI_KEY);
         } else {
             $className = ucfirst($firstParam) . 'Controller';
             if (class_exists($className) && is_subclass_of(new $className(), 'AbstractController')) {
                 $resource->setKey($className::MODULE_KEY);
             } else {
                 if (!empty($firstParam) && !empty($secondParam) && !empty($thirdParam)) {
                     $resource->setKey(Constants::EXPLORER_URI_KEY);
                 } else {
                     $resource->setKey(Constants::INDEX_URI_KEY);
                 }
             }
         }
     } else {
         $resource->setKey(Constants::AUTH_URI_KEY);
         if ($firstParam !== Constants::AUTH_URI_KEY) {
             RequestManager::setPendingRequestURI();
         }
     }
     $resource = self::setCorrectParams($resource, array($firstParam, $secondParam, $thirdParam));
     return $resource;
 }