Fix percorsi API

This commit is contained in:
Thomas Zilio 2019-02-21 09:58:01 +01:00
parent 2a464c931d
commit e78c6fc185
3 changed files with 11 additions and 25 deletions

View File

@ -149,7 +149,7 @@ class AJAX
*
* @return array
*/
protected static function find($file, $permissions = true)
public static function find($file, $permissions = true)
{
$dirname = substr($file, 0, strrpos($file, '/') + 1);

View File

@ -230,25 +230,7 @@ class API extends \Util\Singleton
if (!is_array(self::$resources)) {
$resources = [];
// Ignore dei warning
$resource = '';
// File nativi
$files = glob(DOCROOT.'/modules/*/api/{retrieve,create,update,delete}.php', GLOB_BRACE);
// File personalizzati
$custom_files = glob(DOCROOT.'/modules/*/custom/api/{retrieve,create,update,delete}.php', GLOB_BRACE);
// Pulizia dei file nativi che sono stati personalizzati
foreach ($custom_files as $key => $value) {
$index = array_search(str_replace('custom/api/', 'api/', $value), $files);
if ($index !== false) {
unset($files[$index]);
}
}
$operations = array_merge($files, $custom_files);
asort($operations);
$operations = AJAX::find('api/{retrieve,create,update,delete}.php', false);
foreach ($operations as $operation) {
// Individua la tipologia e il modulo delle operazioni

View File

@ -11,7 +11,7 @@ trait PathTrait
*
* @return string
*/
public function getPath()
public function getPathAttribute()
{
return $this->main_folder.'/'.$this->directory;
}
@ -19,21 +19,25 @@ trait PathTrait
/**
* Restituisce il percorso completo per il file indicato della struttura.
*
* @return string
* @param $file
*
* @return string|null
*/
public function filepath($file)
{
return App::filepath($this->getPath().'|custom|', $file);
return App::filepath($this->path.'|custom|', $file);
}
/**
* Restituisce l'URL completa per il file indicato della struttura.
*
* @return string
* @param $file
*
* @return string|null
*/
public function fileurl($file)
{
$filepath = App::filepath($this->getPath().'|custom|', $file);
$filepath = App::filepath($this->path.'|custom|', $file);
$result = str_replace(DOCROOT, ROOTDIR, $filepath);
$result = str_replace('\\', '/', $result);