Skip to content

Commit

Permalink
added module version and attribute helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Dec 25, 2020
1 parent 480a26c commit 34f2322
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,46 @@ function module($alias = null)
}
}

if (!function_exists('module_attribute')) {
/**
* Get an attribute from module.json file
*
* @param string $alias
* @param string $attribute
*
* @return mixed
*/
function module_attribute($alias, $attribute)
{
return app('module')->get($alias)->get($attribute);
}
}

if (!function_exists('module_version')) {
/**
* Get the module version
*
* @param string $alias
*
* @return mixed
*/
function module_version($alias)
{
return app('module')->get($alias)->get('version');
}
}

if (!function_exists('module_path')) {
/**
* Get the module path
*
* @param string $alias
*
* @return mixed
*/
function module_path($alias, $path = '')
{
$module = app('module')->find($alias);

return $module->getPath() . ($path ? '/' . $path : $path);
return app('module')->get($alias)->getPath() . ($path ? '/' . $path : $path);
}
}

Expand Down

0 comments on commit 34f2322

Please sign in to comment.