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)
This commit is contained in:
parent
80b832e90c
commit
60d6cc5806
@ -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/
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user