ModuleHandlerInterface
interface ModuleHandlerInterface (View source)
Interface for classes that manage a set of enabled modules.
Classes implementing this interface work with a fixed list of modules and are responsible for loading module files and maintaining information about module dependencies and hook implementations.
Methods
Includes a module's .module file.
Loads all enabled modules.
Returns whether all modules have been loaded.
Reloads all enabled modules.
Returns the list of currently active modules.
Returns a module extension object from the currently active modules list.
Sets an explicit list of currently active modules.
Adds a module to the list of currently active modules.
Adds an installation profile to the list of currently active modules.
Determines which modules require and are required by each module.
Determines whether a given module is enabled.
Loads an include file for each enabled module.
Loads a module include file.
Retrieves a list of hooks that are declared through hook_hook_info().
Determines which modules are implementing a hook.
Write the hook implementation info to the cache.
Resets the cached list of hook implementations.
Returns whether a given module implements a given hook.
Invokes a hook in a particular module.
Invokes a hook in all enabled modules that implement it.
Invokes a deprecated hook in a particular module.
Invokes a deprecated hook in all enabled modules that implement it.
Passes alterable variables to specific hook_TYPE_alter() implementations.
Passes alterable variables to deprecated hook_TYPE_alter() implementations.
Returns an array of directories for all enabled modules. Useful for tasks such as finding a file that exists in all module directories.
Gets the human readable name of a given module.
Details
bool
load(string $name)
Includes a module's .module file.
This prevents including a module more than once.
loadAll()
Loads all enabled modules.
bool
isLoaded()
Returns whether all modules have been loaded.
reload()
Reloads all enabled modules.
Extension[]
getModuleList()
Returns the list of currently active modules.
Extension
getModule(string $name)
Returns a module extension object from the currently active modules list.
setModuleList(array $module_list = [])
Sets an explicit list of currently active modules.
addModule(string $name, string $path)
Adds a module to the list of currently active modules.
addProfile(string $name, string $path)
Adds an installation profile to the list of currently active modules.
The
buildModuleDependencies(array $modules)
Determines which modules require and are required by each module.
bool
moduleExists(string $module)
Determines whether a given module is enabled.
loadAllIncludes(string $type, string $name = NULL)
Loads an include file for each enabled module.
string|false
loadInclude(string $module, string $type, string $name = NULL)
Loads a module include file.
Examples:
array
getHookInfo()
Retrieves a list of hooks that are declared through hook_hook_info().
array
getImplementations(string $hook)
Determines which modules are implementing a hook.
writeCache()
Write the hook implementation info to the cache.
resetImplementations()
Resets the cached list of hook implementations.
bool
implementsHook(string $module, string $hook)
Returns whether a given module implements a given hook.
mixed
invoke(string $module, string $hook, array $args = [])
Invokes a hook in a particular module.
array
invokeAll(string $hook, array $args = [])
Invokes a hook in all enabled modules that implement it.
mixed
invokeDeprecated(string $description, string $module, string $hook, array $args = [])
Invokes a deprecated hook in a particular module.
Invoking a deprecated hook adds the behavior of triggering an E_USER_DEPRECATED error if any implementations are found.
API maintainers should use this method instead of invoke() when their hook is deprecated. This method does not detect when a hook is deprecated.
array
invokeAllDeprecated(string $description, string $hook, array $args = [])
Invokes a deprecated hook in all enabled modules that implement it.
Invoking a deprecated hook adds the behavior of triggering an E_USER_DEPRECATED error if any implementations are found.
API maintainers should use this method instead of invokeAll() when their hook is deprecated. This method does not detect when a hook is deprecated.
alter(string|array $type, mixed $data, mixed $context1 = NULL, mixed $context2 = NULL)
Passes alterable variables to specific hook_TYPE_alter() implementations.
This dispatch function hands off the passed-in variables to type-specific hook_TYPE_alter() implementations in modules. It ensures a consistent interface for all altering operations.
A maximum of 2 alterable arguments is supported. In case more arguments need to be passed and alterable, modules provide additional variables assigned by reference in the last $context argument:
alterDeprecated(string $description, string|array $type, mixed $data, mixed $context1 = NULL, mixed $context2 = NULL)
Passes alterable variables to deprecated hook_TYPE_alter() implementations.
This method triggers an E_USER_DEPRECATED error if any implementations of the alter hook are found. It is otherwise identical to alter().
See the documentation for alter() for more details.
array
getModuleDirectories()
Returns an array of directories for all enabled modules. Useful for tasks such as finding a file that exists in all module directories.
string
getName(string $module)
Gets the human readable name of a given module.