public function getClass($param, $exportReq)
 {
     # need at least 1 param for this store procedure
     if (isset($param[0])) {
         # always force exec_proc when csv requested
         if ($exportReq) {
             $a = $this->conn->exec_proc('get_students_for_survey', $param, $exportReq);
             return $a;
         }
         # build manifest
         $attr = splice::getEndpointAttr($_SESSION['j']['endpoints'], $this);
         $respStarter = splice::respManifest($attr['id'], $attr['name'], $attr['version'], $attr['options']);
         # cache state | exec_proc
         $a = phpFastCache::get('student_survey' . $param[0]);
         if ($a == null) {
             $a = $this->conn->exec_proc('get_students_for_survey', $param, $exportReq);
             phpFastCache::set('student_survey' . $param[0], json_decode($a));
         } else {
             $a = json_encode($a, JSON_PRETTY_PRINT);
         }
         ##
         $res = str_replace('%__dataset__%', $a, $respStarter);
         return $res;
     } else {
         throw new \Exception('-- missing params --');
     }
 }
 public function getPosseStudent($param, $app)
 {
     # csv export handler; determine $this->exportReq
     $param = parse::parseParam($param, $this);
     $this->posseStudentResult = self::$studentModel->getPosseStudent($param, $this->exportReq);
     if ($this->exportReq) {
         # set headers/create csv file
         export::exportData($this->posseStudentResult);
     } else {
         $decodeResult = json_decode($this->posseStudentResult, true);
         $this->posseStudentResultTotal = count($decodeResult['DATA']);
     }
     $app->response->headers->set('X-Total-Count', $this->posseStudentResultTotal);
     $app->response->headers->set('Content-Type', 'application/vnd.vassar+json');
     $app->response->setBody($this->posseStudentResult);
 }
 public function getPosseStudent($param, $app)
 {
     # csv export handler; determine $this->exportReq
     $param = parse::parseParam($param, $this);
     $this->posseStudentResult = self::$studentModel->getPosseStudent($param, $this->exportReq);
     # X-Total-Count header
     $decodeResult = json_decode($this->posseStudentResult, true);
     $this->posseStudentResultTotal = count($decodeResult['DATA']);
     if ($this->exportReq) {
         # set headers/create csv file
         export::exportData($this->posseStudentResult);
     }
     $app->response->headers->set('X-Total-Count', $this->posseStudentResultTotal);
     if ($_SESSION['print_pretty'] === 'true') {
         $app->response->setBody("<pre>" . $this->posseStudentResult . "</pre>");
     } else {
         $app->response->setBody($this->posseStudentResult);
     }
 }
 public function getPosseStudent($param, $exportReq)
 {
     # always force exec_proc when csv requested
     if ($exportReq) {
         $a = $this->conn->exec_proc('get_posse_students', $param, $exportReq);
         return $a;
     }
     # build manifest
     $attr = splice::getEndpointAttr($_SESSION['j']['endpoints'], $this);
     $respStarter = splice::respManifest($attr['id'], $attr['name'], $attr['version'], $attr['options']);
     ##
     # cache state | exec_proc
     $a = phpFastCache::get('posse');
     if ($a == null) {
         $a = $this->conn->exec_proc('get_posse_students', $param, $exportReq);
         phpFastCache::set('posse', json_decode($a));
     } else {
         $a = json_encode($a, JSON_PRETTY_PRINT);
     }
     ##
     $res = str_replace('%__dataset__%', $a, $respStarter);
     return $res;
 }
$app->notFound(function () use($app) {
    $app->twig->display('error.php');
});
# Exception handler inside app()
$app->error(function (\Exception $e) use($app) {
    $app->twig->display('error.php');
});
# auth
if (!isset($_GET['client-id'])) {
    # Basic Authentication /vassarapi
    # use an authenticator() ? github/tuupola/slim-basic-auth
    $user_array = array("user-acct2" => "user-acct2", "user-acct1" => "user-acct1");
    $users = array("users" => $user_array);
    $app->add(new \Slim\Middleware\HttpBasicAuthentication(["path" => "/vassarapi", "realm" => "Protected", "authenticator" => new ArrayAuthenticator($users)]));
} else {
    if (!sigValidate::validSignature(consumer::$clientId, $_GET['client-signature'], $_GET['timestamp'])) {
        throw new Exception('invalid login attempt');
    }
}
#
# for each valid endpoint
foreach ($_SESSION['j']['endpoints'] as $endpoint) {
    # for each valid request type inside that endpoint ['get', 'post', 'put', 'delete']
    foreach ($endpoint['http'] as $http) {
        # does consumer have authority on this service?
        foreach (consumer::$clientScope as $clientScope) {
            foreach ($clientScope['control'] as $clientScopeControl) {
                # match in clients scope list and current endpoint/req type; route the request in app()
                if ($clientScope['endpoint'] === $endpoint['uri'] && $clientScopeControl['method'] === $_SERVER['REQUEST_METHOD']) {
                    $app->{$http}['req-type']($endpoint['uri'] . '(/)(/:param+)', function ($param = NULL) use($endpoint, $http, $app) {
                        $className = "\\" . $endpoint['ns'] . "\\" . $endpoint['class'];