From 9f526c512dceabf009a7d42e4ee9b96ef549d060 Mon Sep 17 00:00:00 2001 From: Xebax Date: Wed, 15 Jun 2016 22:53:05 +0200 Subject: [PATCH] REST API: sort the classes before adding them to Restler. The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. --- htdocs/api/index.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index e0abd839b66..e58d2370be7 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -65,6 +65,8 @@ $api->r->addAPIClass('Luracast\\Restler\\Explorer'); $api->r->setSupportedFormats('JsonFormat', 'XmlFormat'); $api->r->addAuthenticationClass('DolibarrApiAccess',''); +$listofapis = array(); + $modulesdir = dolGetModulesDirs(); foreach ($modulesdir as $dir) { @@ -117,7 +119,7 @@ foreach ($modulesdir as $dir) if (class_exists($classname)) { dol_syslog("Found API classname=".$classname); - $api->r->addAPIClass($classname); + $listofapis[] = $classname; } } } @@ -128,6 +130,14 @@ foreach ($modulesdir as $dir) } } +// Sort the classes before adding them to Restler. The Restler API Explorer +// shows the classes in the order they are added and it's a mess if they are +// not sorted. +sort($listofapis); +foreach ($listofapis as $classname) +{ + $api->r->addAPIClass($classname); +} // TODO If not found, redirect to explorer