Beispiel #1
0
 static function parseRelationsFromMySQL($relationsArray)
 {
     ResterUtils::Log(">>> Processing Relations from MySQL");
     $relations = array();
     foreach ($relationsArray as $r) {
         $relation = new MySQLRouteRelation();
         $relation->relationName = $r["CONSTRAINT_NAME"];
         $relation->route = $r["TABLE_NAME"];
         $relation->field = $r["COLUMN_NAME"];
         $relation->destinationRoute = $r["REFERENCED_TABLE_NAME"];
         $relation->destinationField = $r["REFERENCED_COLUMN_NAME"];
         $relations[$relation->route][] = $relation;
     }
     ResterUtils::Dump($relations);
     return $relations;
 }
Beispiel #2
0
 function processRequest($requestMethod)
 {
     ResterUtils::Log("*** BEGIN PROCESSING REQUEST " . $requestMethod . " *** ==> " . $this->getRoutePath());
     $this->checkAuthentication();
     if (isset($this->requestProcessors[$requestMethod])) {
         foreach ($this->requestProcessors[$requestMethod] as $callback) {
             ResterUtils::Log(">> Found processor callback");
             $callbackParameters = array();
             if ($this->getCurrentRoute() && $this->getCurrentRoute() != "/") {
                 $callbackParameters[0] = $this->getCurrentRoute();
                 ResterUtils::Log(">> Processing route /" . $this->getCurrentRoute());
                 if (count($this->getCurrentPath()) > 0) {
                     $callbackParameters[1] = $this->getCurrentPath();
                     ResterUtils::Log(">> Processing command " . implode("/", $this->getCurrentPath()));
                 } else {
                     $callbackParameters[1] = NULL;
                 }
                 if ($requestMethod == "GET") {
                     parse_str($_SERVER['QUERY_STRING'], $requestParameters);
                 } else {
                     if ($requestMethod == "POST") {
                         $requestParameters = $_POST;
                     }
                 }
                 if (isset($requestParameters)) {
                     $callbackParameters[2] = $requestParameters;
                     ResterUtils::Log(">> PARAMETERS: " . http_build_query($requestParameters));
                     ResterUtils::Dump($requestParameters);
                 }
             }
             try {
                 if (isset($callbackParameters) && count($callbackParameters) > 0) {
                     call_user_func_array($callback, $callbackParameters);
                 } else {
                     call_user_func($callback);
                 }
             } catch (Exception $e) {
                 return false;
             }
         }
     } else {
         ResterUtils::Log("*** ERROR *** Request processor not set " . $requestMethod);
         $this->showError(405);
     }
 }