Commit d7aa6e6d authored by thiaramus's avatar thiaramus
Browse files

Put user data and config to the API endpoint classes vars

parent d15014ff
......@@ -24,13 +24,17 @@
abstract class mainApiParent
{
protected $apiCallPath;
protected $user;
protected $config;
// A list of allowed HTTP methods (GET, POST, PATCH, PUT, DELETE) for the API endpoint class.
// Should be overwritten by the child classes.
protected $allowedHttpMethods = [];
public function __construct($params) {
public function __construct($params, $user, $config) {
$this->parseApiCallParams($params);
$this->user = $user;
$this->config = $config;
$this->validate();
}
......
......@@ -47,10 +47,9 @@
$apiClassName = 'api' . ucfirst($apiCallPath[0]);
// Autoload a matching class or return an error message if there is no such class
try {
if (class_exists($apiClassName)) {
$apiClass = new $apiClassName($parsedUri);
$apiClass = new $apiClassName($parsedUri, $user, $cfg);
if (is_a($apiClass, 'mainApiParent')) {
$apiClass->run();
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment