/**
* Get module by name (real, eg 'Breadcrumbs' or folder, eg 'mod_breadcrumbs')
*
* @param string $name The name of the module
* @param string $title The title of the module, optional
*
* @return \stdClass The Module object
*
* @since 1.5
*/
public static function &getModule($name, $title = null)
{
$result = null;
$modules =& static::load();
$total = \count($modules);
for ($i = 0; $i < $total; $i++) {
// Match the name of the module
if ($modules[$i]->name === $name || $modules[$i]->module === $name) {
// Match the title if we're looking for a specific instance of the module
if (!$title || $modules[$i]->title === $title) {
// Found it
$result =& $modules[$i];
break;
}
}
}
// If we didn't find it, and the name is mod_something, create a dummy object
if ($result === null && strpos($name, 'mod_') === 0) {
$result = static::createDummyModule();
$result->module = $name;
}
return $result;
}