You are here

public function ModuleHandler::getModule in Service Container 7.2

Same name and namespace in other branches
  1. 7 src/Extension/ModuleHandler.php \Drupal\service_container\Extension\ModuleHandler::getModule()

Returns a module extension object from the currently active modules list.

Parameters

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

Return value

\Drupal\Core\Extension\Extension An extension object.

Throws

\InvalidArgumentException Thrown when the requested module does not exist.

Overrides ModuleHandlerInterface::getModule

1 call to ModuleHandler::getModule()
ModuleHandler::getModuleList in src/Extension/ModuleHandler.php
Returns the list of currently active modules.

File

src/Extension/ModuleHandler.php, line 95
Contains Drupal\service_container\Extension\ModuleHandler.

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\service_container\Extension

Code

public function getModule($name) {
  if (!$this->drupal7
    ->module_exists($name)) {
    throw new \InvalidArgumentException(sprintf('The module %s does not exist.', $name));
  }
  $filename = $this->drupal7
    ->drupal_get_filename('module', $name);
  return new Extension($this->root, 'module', $filename, $name . '.info');
}