Skip to content

Commit

Permalink
Merge pull request #259 from psoots/helper-wrap
Browse files Browse the repository at this point in the history
Wrap module_ helpers in function_exists conditionals
  • Loading branch information
kaidesu authored Nov 1, 2016
2 parents 007d86a + bbb4376 commit f8ddedc
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions src/Helpers/module.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
<?php

/**
* Return the path to the given module file.
*
* @param string $module
* @param string $file
* @return string
*/
function module_path($module = null, $file = '')
{
if (is_null($module)) {
if (empty($file)) {
return config('modules.path');
if (! function_exists('module_path')) {
/**
* Return the path to the given module file.
*
* @param string $module
* @param string $file
* @return string
*/
function module_path($module = null, $file = '')
{
if (is_null($module)) {
if (empty($file)) {
return config('modules.path');
}

return config('modules.path').'/'.$file;
}

return config('modules.path').'/'.$file;
}
$module = Module::where('slug', $module);

$module = Module::where('slug', $module);
if (empty($file)) {
return config('modules.path').'/'.$module['basename'];
}

if (empty($file)) {
return config('modules.path').'/'.$module['basename'];
return config('modules.path').'/'.$module['basename'].'/'.$file;
}

return config('modules.path').'/'.$module['basename'].'/'.$file;
}

/**
* Return the full path to the given module class.
*
* @param string $slug
* @param string $class
* @return string
*/
function module_class($module, $class)
{
$module = Module::where('slug', $module);
$namespace = config('modules.namespace').$module['basename'];

return "{$namespace}\\{$class}";

if (! function_exists('module_class')) {
/**
* Return the full path to the given module class.
*
* @param string $module
* @param string $class
* @return string
*/
function module_class($module, $class)
{
$module = Module::where('slug', $module);
$namespace = config('modules.namespace').$module['basename'];

return "{$namespace}\\{$class}";
}
}

0 comments on commit f8ddedc

Please sign in to comment.