diff --git a/Libraries/VaahModule.php b/Libraries/VaahModule.php index ad389e1..4f2fded 100644 --- a/Libraries/VaahModule.php +++ b/Libraries/VaahModule.php @@ -15,17 +15,17 @@ function getVaahCmsModulesPath() return config('vaahcms.modules_path'); } //----------------------------------------------------------------------------------- - function getModuleRootPath($module_name) + function getRootPath($module_name) { return $this->getVaahCmsModulesPath()."/".$module_name; } //----------------------------------------------------------------------------------- - function getModuleRelativePath($module_name) + function getRelativePath($module_name) { return "/VaahCms/Modules/".$module_name; } //----------------------------------------------------------------------------------- - function getAllModulesPaths() + function getAllPaths() { $found_modules = []; @@ -41,9 +41,9 @@ function getAllModulesPaths() } //----------------------------------------------------------------------------------- - function getAllModulesNames() + function getAllNames() { - $list = $this->getAllModulesPaths(); + $list = $this->getAllPaths(); $names = null; @@ -58,9 +58,9 @@ function getAllModulesNames() return $names; } //----------------------------------------------------------------------------------- - function getModuleConfigs($module_name) + function getConfigs($module_name) { - $path_settings = $this->getModuleRootPath($module_name).'/Config/config.php'; + $path_settings = $this->getRootPath($module_name).'/Config/config.php'; $config = require $path_settings; @@ -72,9 +72,9 @@ function getModuleConfigs($module_name) return null; } //----------------------------------------------------------------------------------- - function getModuleConfig($module_name, $key) + function getConfig($module_name, $key) { - $configs = $this->getModuleConfigs($module_name); + $configs = $this->getConfigs($module_name); if(!isset($configs[$key])) { @@ -84,7 +84,35 @@ function getModuleConfig($module_name, $key) return $configs[$key]; } //----------------------------------------------------------------------------------- - function getModuleAssetsUrl($module_name, $file_path) + function getVersion($module_name) + { + $composer_path = $this->getRootPath($module_name).'/composer.json'; + + $composer_path = json_decode(file_get_contents($composer_path), true); + + if(!isset($composer_path['version'])) + { + return null; + } + + return $composer_path['version']; + } +//----------------------------------------------------------------------------------- + function getVersionNumber($module_name) + { + $version = $this->getVersion($module_name); + + $version_number = null; + + if(isset($version)) + { + $version_number = preg_replace("/[^0-9\.]/", '', $version); + } + + return $version_number; + } +//----------------------------------------------------------------------------------- + function getAssetsUrl($module_name, $file_path) { $slug = \Str::slug($module_name); $version = config($slug.'.version'); @@ -92,42 +120,42 @@ function getModuleAssetsUrl($module_name, $file_path) return $url; } //----------------------------------------------------------------------------------- - function getModuleMigrationPath($module_name) + function getMigrationPath($module_name) { $path =config('vaahcms.modules_path')."/".$module_name."/Database/Migrations/"; $path = str_replace(base_path()."/", "", $path); return $path; } //----------------------------------------------------------------------------------- - function getModuleSeedsClass($module_name) + function getSeedsClass($module_name) { return config('vaahcms.root_folder')."\Modules\\{$module_name}\\Database\Seeds\DatabaseTableSeeder"; } //----------------------------------------------------------------------------------- - function getModuleTenantMigrationPath($module_name) + function getTenantMigrationPath($module_name) { $path =config('vaahcms.modules_path')."/".$module_name."/Database/Migrations/Tenants"; $path = str_replace(base_path()."/", "", $path); return $path; } //----------------------------------------------------------------------------------- - function getModuleTenantSeedsClass($module_name) + function getTenantSeedsClass($module_name) { return config('vaahcms.root_folder')."\Modules\\{$module_name}\\Database\Seeds\\Tenants\\DatabaseTableSeeder"; } //----------------------------------------------------------------------------------- - function getModuleTenantSampleData($module_name) + function getTenantSampleData($module_name) { return config('vaahcms.root_folder')."\Modules\\{$module_name}\\Database\Seeds\\Tenants\\SampleTableSeeder"; } //----------------------------------------------------------------------------------- - function getModuleNamespace($module_name) + function getNamespace($module_name) { $namespace = "VaahCms\Modules\\".$module_name; return $namespace; } //----------------------------------------------------------------------------------- - function getModuleServiceProvider($module_name) + function getServiceProvider($module_name) { $provider = "VaahCms\Modules\\".$module_name."\\Providers\\".$module_name."ServiceProvider"; return $provider; diff --git a/README.md b/README.md index ce48934..5a9634e 100644 --- a/README.md +++ b/README.md @@ -71,19 +71,21 @@ Add Facade in `config/app.php`: **Method** ```php -\VaahModule::getVaahCmsModulesPath(); -\VaahModule::getModuleRootPath($module_name); -\VaahModule::getModuleRelativePath($module_name); -\VaahModule::getAllModulesPaths(); -\VaahModule::getAllModulesNames(); -\VaahModule::getModuleConfigs($module_name); -\VaahModule::getModuleConfig($module_name, $key); -\VaahModule::getModuleAssetsUrl($module_name, $file_path); -\VaahModule::getModuleMigrationPath($module_name); -\VaahModule::getModuleSeedsClass($module_name); -\VaahModule::getModuleTenantMigrationPath($module_name); -\VaahModule::getModuleTenantSeedsClass($module_name); -\VaahModule::getModuleTenantSampleData($module_name); -\VaahModule::getModuleNamespace($module_name); -\VaahModule::getModuleServiceProvider($module_name); +\VaahModule::getVaahCmsPath(); +\VaahModule::getRootPath($module_name); +\VaahModule::getRelativePath($module_name); +\VaahModule::getAllPaths(); +\VaahModule::getAllNames(); +\VaahModule::getConfigs($module_name); +\VaahModule::getConfig($module_name, $key); +\VaahModule::getVersion($module_name); +\VaahModule::getVersionNumber($module_name); +\VaahModule::getAssetsUrl($module_name, $file_path); +\VaahModule::getMigrationPath($module_name); +\VaahModule::getSeedsClass($module_name); +\VaahModule::getTenantMigrationPath($module_name); +\VaahModule::getTenantSeedsClass($module_name); +\VaahModule::getTenantSampleData($module_name); +\VaahModule::getNamespace($module_name); +\VaahModule::getServiceProvider($module_name); ``` diff --git a/VaahLaravelServiceProvider.php b/VaahLaravelServiceProvider.php index a303472..f699e74 100644 --- a/VaahLaravelServiceProvider.php +++ b/VaahLaravelServiceProvider.php @@ -55,6 +55,7 @@ private function registerAlias() { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('VaahArtisan', \WebReinvent\VaahLaravel\Facades\VaahArtisan::class); + $loader->alias('VaahCountry', \WebReinvent\VaahLaravel\Facades\VaahCountry::class); $loader->alias('VaahModule', \WebReinvent\VaahLaravel\Facades\VaahModule::class); }