Skip to content
Snippets Groups Projects
Commit 60d6cc58 authored by Jean-François Ferry's avatar Jean-François Ferry
Browse files

Modify search of API classes for module

A module can now bring several API classes.
By example, thirdparty module can have api_thirdparty.class.php for thirdparty and api_contact.class.php for contacts.

Classes must be named <Object>API (ie ThirdpartyApi or ContactApi)
parent 80b832e9
No related branches found
No related tags found
No related merge requests found
......@@ -88,19 +88,29 @@ foreach ($modulesdir as $dir)
/*
* If exists, load the API class for enable module
*
* Search a file api_<object>.class.php into /htdocs/<module>/class directory
* Search files named api_<object>.class.php into /htdocs/<module>/class directory
*
* @todo : take care of externals module!
* @todo : use getElementProperties() function
* @todo : use getElementProperties() function ?
*/
$file = DOL_DOCUMENT_ROOT.'/'.$part."/class/api_".$obj.".class.php";
$classname = ucwords($obj).'Api';
if (file_exists($file))
$dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/';
$handle_part=@opendir(dol_osencode($dir_part));
if (is_resource($handle_part))
{
require_once $file;
$api->r->addAPIClass($classname,'');
while (($file_searched = readdir($handle_part))!==false)
{
if (is_readable($dir_part.$file_searched) && preg_match("/^(api_.*)\.class\.php$/i",$file_searched,$reg))
{
$classname=$reg[1];
$classname = str_replace('Api_','',ucwords($reg[1])).'Api';
require_once $dir_part.$file_searched;
if(class_exists($classname))
$api->r->addAPIClass($classname,'');
}
}
}
}
}
}
......
......@@ -90,7 +90,9 @@ class ThirdpartyApi extends DolibarrApi {
}
/**
* Fetch a list of thirdparties
* List thirdparties
*
* Get a list of thirdparties
*
* @url GET /thirdparties/
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment