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.
This commit is contained in:
Xebax 2016-06-15 22:53:05 +02:00
parent f6eac2b643
commit 9f526c512d

View File

@ -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