summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2020-01-10 22:10:07 +0100
committeremkael <emkael@tlen.pl>2020-01-10 22:10:07 +0100
commit27d32d8b5b5a6bab278bebaafdb2c07d38778701 (patch)
tree8414ff6cc4144bde3dee97e05e5e39a4e80513e1
parentda6bfb561a092dfb9956f0f97512a64c07add2b7 (diff)
Selection of API class depending on privided version
-rw-r--r--http/api-inc.php2
-rw-r--r--http/api.php9
2 files changed, 10 insertions, 1 deletions
diff --git a/http/api-inc.php b/http/api-inc.php
index 40aa612..041c8ff 100644
--- a/http/api-inc.php
+++ b/http/api-inc.php
@@ -201,4 +201,6 @@ class ApiPkl {
}
}
+class ApiPklV1 extends ApiPkl {}
+
?>
diff --git a/http/api.php b/http/api.php
index b0140b9..ea633e3 100644
--- a/http/api.php
+++ b/http/api.php
@@ -31,8 +31,15 @@ Parametry:
require_once('api-inc.php');
function run($parameters) {
+
try {
- $api = new ApiPkl($parameters);
+ $versionClasses = array(
+ '1' => 'ApiPklV1', // RegKlas 2018.11.01
+ '_default' => 'ApiPklV1'
+ );
+ $version = isset($parameters['version']) ? $parameters['version'] : '_default';
+ $apiClass = isset($versionClasses[$version]) ? $versionClasses[$version] : $versionClasses['_default'];
+ $api = new $apiClass($parameters);
if ($parameters['tournament_rank'] == ApiPkl::RANK_KMP) {
$result = $api->calculate_kmp_points();
} else {