You are here

public function ModuleHandler::load in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::load()

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

1 call to ModuleHandler::load()
ModuleHandler::loadAll in core/lib/Drupal/Core/Extension/ModuleHandler.php
Loads all enabled modules.

File

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

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;
}