From 9aba233a9349c0e8b6c3ebab142e77acb77bcaa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Wed, 25 Oct 2023 11:20:01 +0300 Subject: [PATCH] added method to get available modules --- src/FileRepository.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/FileRepository.php b/src/FileRepository.php index 5a811b0..5011c64 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -308,6 +308,30 @@ public function getOrdered($direction = 'asc') : array return $modules; } + /** + * Get all available modules. + * + * @return array + */ + public function getAvailable() + { + $paths = $this->getScanPaths(); + + $modules = []; + + foreach ($paths as $key => $path) { + $manifests = $this->getFiles()->glob("{$path}/module.json"); + + is_array($manifests) || $manifests = []; + + foreach ($manifests as $manifest) { + $modules[] = Json::make($manifest)->get('alias'); + } + } + + return $modules; + } + /** * Get a module path. *