From e78c6fc185d28575721bc00b5bae9f2e15e91e03 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Thu, 21 Feb 2019 09:58:01 +0100 Subject: [PATCH] Fix percorsi API --- src/AJAX.php | 2 +- src/API.php | 20 +------------------- src/Traits/PathTrait.php | 14 +++++++++----- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/AJAX.php b/src/AJAX.php index 657383673..4e0aee995 100644 --- a/src/AJAX.php +++ b/src/AJAX.php @@ -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); diff --git a/src/API.php b/src/API.php index f556fe24b..791b95984 100644 --- a/src/API.php +++ b/src/API.php @@ -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 diff --git a/src/Traits/PathTrait.php b/src/Traits/PathTrait.php index cc09753b1..bf01244f7 100644 --- a/src/Traits/PathTrait.php +++ b/src/Traits/PathTrait.php @@ -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);