mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-10 04:34:29 -06:00
61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Description of BaseController
|
||
|
*
|
||
|
* @author SCTN4
|
||
|
*/
|
||
|
class BaseController {
|
||
|
/**
|
||
|
* __call magic method.
|
||
|
*/
|
||
|
public function __call($name, $arguments)
|
||
|
{
|
||
|
$this->sendOutput('', array('HTTP/1.1 404 Not Found'));
|
||
|
}
|
||
|
/**
|
||
|
* Get URI elements.
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
protected function getUriSegments()
|
||
|
{
|
||
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||
|
$uri = explode( '/', $uri );
|
||
|
return $uri;
|
||
|
}
|
||
|
/**
|
||
|
* Get querystring params.
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
protected function getQueryStringParams()
|
||
|
{
|
||
|
$query = array();
|
||
|
$parameters = parse_str($_SERVER['QUERY_STRING'], $query);
|
||
|
return $query;
|
||
|
}
|
||
|
/**
|
||
|
* Send API output.
|
||
|
*
|
||
|
* @param mixed $data
|
||
|
* @param string $httpHeader
|
||
|
*/
|
||
|
protected function sendOutput($data, $httpHeaders=array())
|
||
|
{
|
||
|
header_remove('Set-Cookie');
|
||
|
if (is_array($httpHeaders) && count($httpHeaders)) {
|
||
|
foreach ($httpHeaders as $httpHeader) {
|
||
|
header($httpHeader);
|
||
|
}
|
||
|
}
|
||
|
echo $data;
|
||
|
exit;
|
||
|
}
|
||
|
}
|