feat: ✨ Added modules namespace
This commit is contained in:
parent
881f5e8bce
commit
4a2b680e5c
|
@ -66,7 +66,8 @@ class Controller extends BaseController
|
|||
* author: string,
|
||||
* version: string,
|
||||
* url: string,
|
||||
* module_path: string
|
||||
* modulePath: string,
|
||||
* namespace: string
|
||||
* }>
|
||||
*/
|
||||
public function getModules(): Collection
|
||||
|
@ -82,8 +83,8 @@ class Controller extends BaseController
|
|||
'author' => $provider::author(),
|
||||
'version' => $provider::version(),
|
||||
'url' => $provider::url(),
|
||||
'module_path' => $provider::modulePath(),
|
||||
'has_bootstrap' => $provider::hasBootstrap(),
|
||||
'modulePath' => $provider::modulePath(),
|
||||
'namespace' => $provider::namespace(),
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use ReflectionClass;
|
||||
|
||||
|
@ -67,11 +66,11 @@ abstract class ModuleServiceProvider extends ServiceProvider
|
|||
|
||||
public static function modulePath(): string
|
||||
{
|
||||
return dirname((new ReflectionClass(static::class))->getFileName());
|
||||
return dirname((new ReflectionClass(static::class))->getFileName(), 2);
|
||||
}
|
||||
|
||||
public static function hasBootstrap(): bool
|
||||
public static function namespace(): string
|
||||
{
|
||||
return File::exists(static::modulePath().DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'ts'.DIRECTORY_SEPARATOR.'bootstrap.tsx');
|
||||
return (new ReflectionClass(static::class))->getNamespaceName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@ class RestifyServiceProvider extends RestifyApplicationServiceProvider
|
|||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewRestify', function ($user) {
|
||||
return in_array($user->email, [
|
||||
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -30,7 +28,7 @@ class RestifyServiceProvider extends RestifyApplicationServiceProvider
|
|||
// Register repositories from modules
|
||||
$modules = app(Controller::class)->getModules();
|
||||
foreach ($modules as $module) {
|
||||
Restify::repositoriesFrom($module['module_path'].DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'Api', app()->getNamespace());
|
||||
Restify::repositoriesFrom($module['modulePath'].DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'Api', $module['namespace'].'\Api\\');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue