Skip to content

Commit

Permalink
[LorisInstance] add getModule function
Browse files Browse the repository at this point in the history
LorisInstance already has functions to check if a module
exists, get the module directories, etc.

This adds a getModule to replace \Module::factory() so that
the code dealing with modules can be centralized in one place.
  • Loading branch information
driusan committed Nov 7, 2022
1 parent c70e615 commit 771bc10
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/LorisInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public function getActiveModules(): array
$modules = [];
foreach ($mnames as $name) {
try {
$modules[] = \Module::factory($this, $name);
$mod = \Module::factory($this, $name);
$modules[] = $mod;
} catch (\LorisModuleMissingException $e) {
error_log($e->getMessage() . " " . $e->getTraceAsString());
}
Expand Down Expand Up @@ -116,6 +117,18 @@ public function hasModule(string $name) : bool
return false;
}

/**
* Get the \Module class for the module named $name,
* if enabled on this LORIS instance or throw an exception
* if it doesn't exist.
*
* @return \Module
*/
public function getModule(string $name) : \Module
{
return \Module::factory($this, $name);
}

/**
* Returns an NDB_Config object used for interacting with configuration
* settings for this instance.
Expand Down

0 comments on commit 771bc10

Please sign in to comment.