Bonjour,
Je cherche à ajouter une API à un module (orderFab de ATM) mais j’ai des problèmes.
Voici mon code
<?php
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/of/class/ordre_fabrication_asset.class.php';
/**
* API class for TAssetOF
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class Modof extends DolibarrApi
{
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'ofid'
);
/**
* @var TAssetOF $assetof {@type TAssetOF}
*/
public $assetof;
/**
* Constructor
*/
function __construct()
{
global $db, $conf;
$this->db = $db;
$this->assetof = new TAssetOF($this->db);
}
/**
* List Of
*
* Get a list of order fab
* @param int $id ID of TAssetOf
* @return string without useless information
*
* @url GET /ordre_fabrication_asset/
*/
function get($id) {
global $db, $conf;
return "cuocou";
}
}
Si je garde le include_once, l’explorer plante avec erreur 500 : undefined http://localhost:8888/doli/htdocs/api/index.php/explorer/resources.json
Si je l’enlève, je peux accéder à la liste des API mais l’explorateur de ne marche pas (je ne peux pas choisir et déplier les listes). Ma console m’indique l’erreur suivante :
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data[En savoir plus] swagger.js:375:41
response
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/swagger.js:375:41
response
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/swagger.js:1523:16
EventEmitter.prototype.emit
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:1391:9
emit
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:1191:13
createRequest/request._raw</response<
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:1211:9
setBodyAndFinish
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:1815:7
Response/<
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:1832:7
EventEmitter.prototype.emit
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:1388:9
Response.prototype.handle
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:2715:14
module.exports/xhr.onreadystatechange
http://localhost:8888/doli/htdocs/api/index.php/explorer/lib/shred.bundle.js:2584:9
J’ai essayer de regarder dans le code de l’explorer mais je n’ai rien trouver.
Je suis à cours d’idée donc je m’en remet à vous.
Merci
Edit : Voici un aperçu de la structure du répertoire dans htdocs
of
|- class
|-- api_modof.class.php
|-- ordre_fabrication_asset.class.php
|-- ....
|- core
|-- modules
|--- modof.class.php
fiche_of.php
liste_of.php