Bonfire includes a Modules library to supplement the modules functionality included in Wiredesignz HMVC.
Many of these methods are intended for internal use, but are public for backwards-compatibility.
Run a module controller method (as indicated by
Output from module is buffered and returned.
$modulecontains a slash, it will be split into
Modules::Run(), they will be passed to the method indicated by
Returns either a directly returned value from the method or the buffered output of the method. If the method was not found, an error is logged and nothing is returned.
Loads a controller in a module.
$module is an array, the first item in the array will be used for
$module, and the remaining items will be used as parameters to be passed to the method.
Returns the loaded controller, or nothing if the controller was not found.
Handles autoloading core and library classes using
BF_ prefixes, along with the
This method is registered with PHP as an autoloader when the Modules library is loaded.
Load a module file.
$file is the name of the file to load.
$path is the path to the file.
$type is the type of file, usually
$result is the value which will be returned, unless
$type is not
'config', the value of
$config will be returned.
Find a file.
Looks for the file within module and application directories.
$file is the file to be found.
$module is the module in which the file should be located.
$base is the type of file (
Returns an array with the first entry containing the full path and the second entry containing the file name.
If the file was not found, the first entry in the array will be
Parse a routes file for a module (from the module’s
config/routes.php file) to locate a route for a given URI.
$module is the module in which the routes file should be located.
$uri is the URI to be found in the routes file.
Returns the parsed route, if found, or nothing.
Determine whether a controller (
$controller) exists in a given module (
$controller must not include the file extension (
This method will return
false if either
$module is empty, or if the
$controller was not found in the
Otherwise, it will return
true (if the
$controller was found in the
$moduleThe module in which the file should be located.
$folderThe folder within the module to search for the file (e.g.
$fileThe name fo the file to search for (including the
Returns the path to a file within a module, if it can be found.
$file is empty, returns false.
If the file is not found, nothing is returned.
$moduleThe name of the module (must match the name of the module’s directory).
$folderThe name of the folder to find within the module’s directory.
Return the path to the specified folder within the specified module. If the folder could not be found, the module’s directory is returned. If the module could not be found, nothing is returned.
Retrieve a list of files within one or more modules.
$module_name If not null, will return only files from this module.
$module_folder If not null, will return only files within this sub-folder (e.g.
true, excludes Bonfire (core) modules.
Returns an associative array of files found in the format:
array( 'module_name' => array( 'folder' => array('file1', 'file2') ) )
If no files were found, returns false.
Returns the ‘module_config’ array from a module’s
This array can be used for custom fields in addition to fields used to supply information to Bonfire for the admin UI.
$module_nameThe name of the module for which the config data will be retrieved.
true and ‘module_config’ is not found, the entire config array will be returned.
$configis not set after including the config file, or
$return_fullis false, or
$return_fullis true and
$configis not an array.
$return_fullis false, and
$configis an array, the value of
Returns an array of the folders in which modules may be stored (these are absolute paths).
Returns a list of modules in the system.
$exclude_core is true, the Bonfire (core) modules will not be included in the list.
The returned array will contain the names of the folders within the module directories.
All of these properties are intended primarily for internal use, but are public for backwards compatibility. In most cases, one or more of the methods will return the information contained in these properties.
An array of module locations, normally retrieved from the
'modules_location' setting in the site’s
The array keys are the canonicalized absolute paths to the modules directories.
The values are relative paths.
The Modules library only uses the keys internally.
A registry of loaded controllers. The keys are the names of the controllers in lowercase. The values are controller instances.
An array of module routes, with the module name as the key and the routes for that module (loaded from the module’s
config/routes.php file) as the value.