-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from psoots/helper-wrap
Wrap module_ helpers in function_exists conditionals
- Loading branch information
Showing
1 changed file
with
37 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"; | ||
} | ||
} |