/**
  * @return Controller
  * @throws BadRequestHttpException
  * @throws ServerErrorHttpException
  */
 private static function createController($object)
 {
     $controllerSimpleClassName = self::getControllerClassName($object);
     $controllerFileName = Controller::getBaseDir() . "/{$controllerSimpleClassName}.php";
     $controllerFullyQualifiedClassName = Controller::getNamespace() . "\\" . $controllerSimpleClassName;
     if (!file_exists($controllerFileName)) {
         throw new BadRequestHttpException("Invalid controller file. Not found.");
     }
     require_once $controllerFileName;
     if (!class_exists($controllerFullyQualifiedClassName)) {
         throw new ServerErrorHttpException("Cannot find controller class.");
     }
     return new $controllerFullyQualifiedClassName();
 }