50 lines
901 B
PHP
50 lines
901 B
PHP
|
<?php
|
||
|
|
||
|
namespace api\core;
|
||
|
|
||
|
use \error\core\Error;
|
||
|
use \error\core\Err;
|
||
|
use \api\core\Request;
|
||
|
use \api\core\Config;
|
||
|
|
||
|
|
||
|
class Documentation{
|
||
|
|
||
|
/* (1) Attributes
|
||
|
---------------------------------------------------------*/
|
||
|
/* (1) Static */
|
||
|
|
||
|
/* (2) Instance */
|
||
|
|
||
|
|
||
|
/* (2) Builds the documentation
|
||
|
*
|
||
|
---------------------------------------------------------*/
|
||
|
public function generate(Request $rq=null){
|
||
|
|
||
|
/* (1) Get data from config
|
||
|
---------------------------------------------------------*/
|
||
|
/* (1) If no index for this path -> exit */
|
||
|
if( !isset(Config::get()->index[$rq->get('id')['path']]) )
|
||
|
return new Response(new Error(Err::WrongPathModule));
|
||
|
|
||
|
/* (2) Local store: configuration for this path */
|
||
|
$cfg = Config::get()->index[$rq->get('id')['path']];
|
||
|
|
||
|
|
||
|
|
||
|
$response = new Response();
|
||
|
$response->append('methods', $cfg);
|
||
|
|
||
|
return $response;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|