Added the ability to add module aliases.

Setting a alias can be done by adding the aliases array to the moduleInfo.php and setting the names in there.
An example can be found in the example module.
This commit is contained in:
Abel Hoogeveen 2015-08-29 21:07:17 +02:00
parent fe4fe7e688
commit aa7bd856f2
3 changed files with 34 additions and 1 deletions

View File

@ -313,6 +313,14 @@ class Modules extends Bus{
// Copy all the data into the register and enable
$register[$name] = (array) $cfg;
$this->logger->log("[ON] '".$name."'");
// Add all module aliases if available
if (isset($cfg->aliases)) {
foreach ($cfg->aliases as $alias) {
$register[$alias] = (array) $cfg;
$this->logger->log("[ON] '".$alias."' (alias of '".$name."')");
}
}
} else {
// If not, copy all the basic data so that it can be enabled in the future
$cfg2 = new StdClass();
@ -321,11 +329,27 @@ class Modules extends Bus{
$cfg2->meta = $cfg;
$register[$name] = (array)$cfg2;
$this->logger->log("[OFF] '".$name."'");
// Add all module aliases if available
if (isset($cfg->aliases)) {
foreach ($cfg->aliases as $alias) {
$register[$alias] = (array) $cfg2;
$this->logger->log("[OFF] '".$alias."' (alias of '".$name."')");
}
}
}
} else {
// Copy all the data into the register and enable
$register[$name] = (array) $cfg;
$this->logger->log("[ON] '".$name."'");
// Add all module aliases if available
if (isset($cfg->aliases)) {
foreach ($cfg->aliases as $alias) {
$register[$alias] = (array) $cfg;
$this->logger->log("[ON] '".$alias."' (alias of '".$name."')");
}
}
}
} else {
// If no details are specified, create a basic module

View File

@ -49,6 +49,14 @@ class Main extends Module {
// Do Something
}
/**
* Test method that can be called
* @return String Example text
*/
public function test() {
return "It works!";
}
}
?>

View File

@ -35,6 +35,7 @@ return array(
'module_name' => 'Example',
'abstract' => false,
'aliases' => array('techfuze/example'),
'dependencies' => array(),
'events' => array(),
'sections' => array(),
@ -48,5 +49,5 @@ return array(
'date_created' => '29-04-2015',
'date_updated' => '29-04-2015',
'enabled' => true,
'enabled' => true
);