W3cubDocs

/Drupal 8

public function ModuleHandler::load

public ModuleHandler::load($name)

Includes a module's .module file.

This prevents including a module more than once.

Parameters

string $name: The name of the module to load.

Return value

bool TRUE if the item is loaded or has already been loaded.

Overrides ModuleHandlerInterface::load

File

core/lib/Drupal/Core/Extension/ModuleHandler.php, line 121

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\Core\Extension

Code

public function load($name) {
  if (isset($this->loadedFiles[$name])) {
    return TRUE;
  }

  if (isset($this->moduleList[$name])) {
    $this->moduleList[$name]->load();
    $this->loadedFiles[$name] = TRUE;
    return TRUE;
  }
  return FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ModuleHandler.php/function/ModuleHandler::load/8.1.x