From 1b030293d003a373ca19cf773ad4e5a16606ae62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 23 Dec 2017 22:24:31 +0100 Subject: [PATCH] repo.php: getRepo() to load repository class --- repo.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/repo.php b/repo.php index bcc9aa99..9eafb511 100644 --- a/repo.php +++ b/repo.php @@ -13,13 +13,22 @@ if (!isset($repositories)) { ); } +function getRepo ($repoId, $repoData) { + switch (array_key_exists('type', $repoData) ? $repoData['type'] : 'dir') { + default: + $repo = new RepositoryDir($repoId, $repoData); + } + + return $repo; +} + if (!isset($_REQUEST['repo'])) { Header("Content-Type: application/json; charset=utf-8"); print '{'; $c = 0; foreach ($repositories as $repoId => $repoData) { - $repo = new RepositoryDir($repoId, $repoData); + $repo = getRepo($repoId, $repoData); print $c++ ? ',' : ''; print json_encode($repoId) . ':'; @@ -36,7 +45,7 @@ if (!array_key_exists($repoId, $repositories)) { exit(0); } -$repo = new RepositoryDir($repoId, $repositories[$repoId]); +$repo = getRepo($repoId, $repositories[$repoId]); $cacheDir = null; $ts = $repo->newestTimestamp($path);