added apiName
This commit is contained in:
@ -21,10 +21,11 @@ class APIlite
|
|||||||
private string $endpoint = '';
|
private string $endpoint = '';
|
||||||
private $methods = array();
|
private $methods = array();
|
||||||
|
|
||||||
public function __construct(?string $format = null, ?string $endpoint = null)
|
public function __construct(?string $format = null, ?string $endpoint = null, ?string $apiName = null)
|
||||||
{
|
{
|
||||||
register_shutdown_function(array($this, '_shutdownHandler'));
|
register_shutdown_function(array($this, '_shutdownHandler'));
|
||||||
$this->endpoint = $endpoint ?? $this->getCurrentUrl();
|
$this->endpoint = $endpoint ?? $this->getCurrentUrl();
|
||||||
|
$this->apiName = $apiName ?? '';
|
||||||
$this->analyzeClass();
|
$this->analyzeClass();
|
||||||
if (isset($_REQUEST['action'])) {
|
if (isset($_REQUEST['action'])) {
|
||||||
$this->doAction($_REQUEST['action']);
|
$this->doAction($_REQUEST['action']);
|
||||||
@ -67,7 +68,9 @@ class APIlite
|
|||||||
private function analyzeClass(): bool
|
private function analyzeClass(): bool
|
||||||
{
|
{
|
||||||
$refClass = new \ReflectionClass($this);
|
$refClass = new \ReflectionClass($this);
|
||||||
$this->apiName = $refClass->getShortName();
|
if (strlen($this->apiName) <= 0) {
|
||||||
|
$this->apiName = $refClass->getShortName();
|
||||||
|
}
|
||||||
$this->methods = array();
|
$this->methods = array();
|
||||||
foreach ($refClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $ref_method) {
|
foreach ($refClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $ref_method) {
|
||||||
$method_name = $ref_method->getName();
|
$method_name = $ref_method->getName();
|
||||||
|
|||||||
Reference in New Issue
Block a user