Skip to content

Commit

Permalink
Changed: Methods of VaahModule
Browse files Browse the repository at this point in the history
  • Loading branch information
themodernpk committed Nov 19, 2020
1 parent fd4b544 commit 55b7e6e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 32 deletions.
62 changes: 45 additions & 17 deletions Libraries/VaahModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -41,9 +41,9 @@ function getAllModulesPaths()

}
//-----------------------------------------------------------------------------------
function getAllModulesNames()
function getAllNames()
{
$list = $this->getAllModulesPaths();
$list = $this->getAllPaths();

$names = null;

Expand All @@ -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;

Expand All @@ -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]))
{
Expand All @@ -84,50 +84,78 @@ 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');
$url = url("vaahcms/modules/".$slug."/assets/".$file_path)."?v=".$version;
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;
Expand Down
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
1 change: 1 addition & 0 deletions VaahLaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down

0 comments on commit 55b7e6e

Please sign in to comment.