mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-08 14:44:29 -06:00
72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
header("Access-Control-Allow-Origin: *");
|
|
header("Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE");
|
|
header("Access-Control-Max-Age: 3600");
|
|
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
|
|
|
/*
|
|
* * Description
|
|
*
|
|
* @author Mike Howard
|
|
*
|
|
* USAGE
|
|
* https://localhost/index.php/{MODULE_NAME}/{METHOD_NAME}?limit={LIMIT_VALUE}
|
|
* http://localhost/index.php/customer/process/list?limit=20
|
|
*/
|
|
require __DIR__ . "/include/bootstrap.php";
|
|
|
|
$requestMethod = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
|
|
$parsedUri = parse_url($requestMethod, PHP_URL_PATH);
|
|
$uri = explode( '/', $parsedUri );
|
|
|
|
//Set uri module location position to 1 for production, 2 for testing
|
|
$uri_pos = 2;
|
|
|
|
/* When testing with UniServer the URI array placement position will be
|
|
* incremented by 1 due to the folder addition
|
|
* http://localhost/CustomerRewardsRESTAPI/index.php/customer/process/select?limit=5
|
|
* uri[1] = folder
|
|
* uri[2] = index
|
|
* uri[3] = module
|
|
* uri[4] = action
|
|
* uri[5] = parmeters
|
|
*/
|
|
|
|
if (!isset($uri[$uri_pos]) || !isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2])) {
|
|
header("HTTP/1.1 404 Not Found");
|
|
exit();
|
|
}
|
|
//echo var_dump($uri);
|
|
switch($uri[$uri_pos + 1]) {
|
|
case "purchase":
|
|
header("HTTP/1.1 404 Module Not Defined");
|
|
exit();
|
|
//$objFeedController = new PurchaseController();
|
|
break;
|
|
|
|
case "customer":
|
|
require PROJECT_ROOT_PATH . "/Controller/Api/CustomerController.php";
|
|
$objFeedController = new CustomerController();
|
|
break;
|
|
|
|
case "attribute":
|
|
require PROJECT_ROOT_PATH . "/Controller/Api/AttributeController.php";
|
|
$objFeedController = new AttributeController();
|
|
break;
|
|
|
|
case "image":
|
|
require PROJECT_ROOT_PATH . "/Controller/Api/ImageController.php";
|
|
$objFeedController = new ImageController();
|
|
break;
|
|
|
|
default:
|
|
header("HTTP/1.1 404 Module Not Found");
|
|
exit();
|
|
break;
|
|
}
|
|
|
|
$strMethodName = $uri[$uri_pos + 2] . 'Action';
|
|
$objFeedController->action = $uri[$uri_pos + 3];
|
|
$objFeedController->{$strMethodName}();
|
|
|