Chris@0: loadInclude('node', 'inc', 'node.admin'); Chris@0: * // Load content_types.inc from the node module. Chris@0: * $this->loadInclude('node', 'inc', 'content_types'); Chris@0: * @endcode Chris@0: * Chris@0: * @param string $module Chris@0: * The module to which the include file belongs. Chris@0: * @param string $type Chris@0: * The include file's type (file extension). Chris@0: * @param string $name Chris@0: * (optional) The base file name (without the $type extension). If omitted, Chris@0: * $module is used; i.e., resulting in "$module.$type" by default. Chris@0: * Chris@0: * @return string|false Chris@0: * The name of the included file, if successful; FALSE otherwise. Chris@0: */ Chris@0: public function loadInclude($module, $type, $name = NULL); Chris@0: Chris@0: /** Chris@0: * Retrieves a list of hooks that are declared through hook_hook_info(). Chris@0: * Chris@0: * @return array Chris@0: * An associative array whose keys are hook names and whose values are an Chris@0: * associative array containing a group name. The structure of the array Chris@0: * is the same as the return value of hook_hook_info(). Chris@0: * Chris@0: * @see hook_hook_info() Chris@0: */ Chris@0: public function getHookInfo(); Chris@0: Chris@0: /** Chris@0: * Determines which modules are implementing a hook. Chris@0: * Chris@0: * @param string $hook Chris@0: * The name of the hook (e.g. "help" or "menu"). Chris@0: * Chris@0: * @return array Chris@0: * An array with the names of the modules which are implementing this hook. Chris@0: */ Chris@0: public function getImplementations($hook); Chris@0: Chris@0: /** Chris@0: * Write the hook implementation info to the cache. Chris@0: */ Chris@0: public function writeCache(); Chris@0: Chris@0: /** Chris@0: * Resets the cached list of hook implementations. Chris@0: */ Chris@0: public function resetImplementations(); Chris@0: Chris@0: /** Chris@0: * Returns whether a given module implements a given hook. Chris@0: * Chris@0: * @param string $module Chris@0: * The name of the module (without the .module extension). Chris@0: * @param string $hook Chris@0: * The name of the hook (e.g. "help" or "menu"). Chris@0: * Chris@0: * @return bool Chris@0: * TRUE if the module is both installed and enabled, and the hook is Chris@0: * implemented in that module. Chris@0: */ Chris@0: public function implementsHook($module, $hook); Chris@0: Chris@0: /** Chris@0: * Invokes a hook in a particular module. Chris@0: * Chris@0: * @param string $module Chris@0: * The name of the module (without the .module extension). Chris@0: * @param string $hook Chris@0: * The name of the hook to invoke. Chris@0: * @param array $args Chris@0: * Arguments to pass to the hook implementation. Chris@0: * Chris@0: * @return mixed Chris@0: * The return value of the hook implementation. Chris@0: */ Chris@0: public function invoke($module, $hook, array $args = []); Chris@0: Chris@0: /** Chris@0: * Invokes a hook in all enabled modules that implement it. Chris@0: * Chris@0: * @param string $hook Chris@0: * The name of the hook to invoke. Chris@0: * @param array $args Chris@0: * Arguments to pass to the hook. Chris@0: * Chris@0: * @return array Chris@0: * An array of return values of the hook implementations. If modules return Chris@0: * arrays from their implementations, those are merged into one array Chris@0: * recursively. Note: integer keys in arrays will be lost, as the merge is Chris@0: * done using array_merge_recursive(). Chris@0: */ Chris@0: public function invokeAll($hook, array $args = []); Chris@0: Chris@0: /** Chris@14: * Invokes a deprecated hook in a particular module. Chris@14: * Chris@14: * Invoking a deprecated hook adds the behavior of triggering an Chris@14: * E_USER_DEPRECATED error if any implementations are found. Chris@14: * Chris@14: * API maintainers should use this method instead of invoke() when their hook Chris@14: * is deprecated. This method does not detect when a hook is deprecated. Chris@14: * Chris@14: * @param string $description Chris@14: * Helpful text describing what to do instead of implementing this hook. Chris@14: * @param string $module Chris@14: * The name of the module (without the .module extension). Chris@14: * @param string $hook Chris@14: * The name of the hook to invoke. Chris@14: * @param array $args Chris@14: * Arguments to pass to the hook implementation. Chris@14: * Chris@14: * @return mixed Chris@14: * The return value of the hook implementation. Chris@14: * Chris@14: * @see \Drupal\Core\Extension\ModuleHandlerInterface::invoke() Chris@14: * @see https://www.drupal.org/core/deprecation#how-hook Chris@14: */ Chris@14: public function invokeDeprecated($description, $module, $hook, array $args = []); Chris@14: Chris@14: /** Chris@14: * Invokes a deprecated hook in all enabled modules that implement it. Chris@14: * Chris@14: * Invoking a deprecated hook adds the behavior of triggering an Chris@14: * E_USER_DEPRECATED error if any implementations are found. Chris@14: * Chris@14: * API maintainers should use this method instead of invokeAll() when their Chris@14: * hook is deprecated. This method does not detect when a hook is deprecated. Chris@14: * Chris@14: * @param string $description Chris@14: * Helpful text describing what to do instead of implementing this hook. Chris@14: * @param string $hook Chris@14: * The name of the hook to invoke. Chris@14: * @param array $args Chris@14: * Arguments to pass to the hook. Chris@14: * Chris@14: * @return array Chris@14: * An array of return values of the hook implementations. If modules return Chris@14: * arrays from their implementations, those are merged into one array Chris@14: * recursively. Note: integer keys in arrays will be lost, as the merge is Chris@14: * done using array_merge_recursive(). Chris@14: * Chris@14: * @see \Drupal\Core\Extension\ModuleHandlerInterface::invokeAll() Chris@14: * @see https://www.drupal.org/core/deprecation#how-hook Chris@14: */ Chris@14: public function invokeAllDeprecated($description, $hook, array $args = []); Chris@14: Chris@14: /** Chris@0: * Passes alterable variables to specific hook_TYPE_alter() implementations. Chris@0: * Chris@0: * This dispatch function hands off the passed-in variables to type-specific Chris@0: * hook_TYPE_alter() implementations in modules. It ensures a consistent Chris@0: * interface for all altering operations. Chris@0: * Chris@0: * A maximum of 2 alterable arguments is supported. In case more arguments need Chris@0: * to be passed and alterable, modules provide additional variables assigned by Chris@0: * reference in the last $context argument: Chris@0: * @code Chris@0: * $context = array( Chris@0: * 'alterable' => &$alterable, Chris@0: * 'unalterable' => $unalterable, Chris@0: * 'foo' => 'bar', Chris@0: * ); Chris@0: * $this->alter('mymodule_data', $alterable1, $alterable2, $context); Chris@0: * @endcode Chris@0: * Chris@0: * Note that objects are always passed by reference in PHP5. If it is absolutely Chris@0: * required that no implementation alters a passed object in $context, then an Chris@0: * object needs to be cloned: Chris@0: * @code Chris@0: * $context = array( Chris@0: * 'unalterable_object' => clone $object, Chris@0: * ); Chris@0: * $this->alter('mymodule_data', $data, $context); Chris@0: * @endcode Chris@0: * Chris@0: * @param string|array $type Chris@0: * A string describing the type of the alterable $data. 'form', 'links', Chris@0: * 'node_content', and so on are several examples. Alternatively can be an Chris@0: * array, in which case hook_TYPE_alter() is invoked for each value in the Chris@0: * array, ordered first by module, and then for each module, in the order of Chris@0: * values in $type. For example, when Form API is using $this->alter() to Chris@0: * execute both hook_form_alter() and hook_form_FORM_ID_alter() Chris@0: * implementations, it passes array('form', 'form_' . $form_id) for $type. Chris@0: * @param mixed $data Chris@0: * The variable that will be passed to hook_TYPE_alter() implementations to be Chris@0: * altered. The type of this variable depends on the value of the $type Chris@0: * argument. For example, when altering a 'form', $data will be a structured Chris@0: * array. When altering a 'profile', $data will be an object. Chris@0: * @param mixed $context1 Chris@0: * (optional) An additional variable that is passed by reference. Chris@0: * @param mixed $context2 Chris@0: * (optional) An additional variable that is passed by reference. If more Chris@0: * context needs to be provided to implementations, then this should be an Chris@0: * associative array as described above. Chris@0: */ Chris@0: public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL); Chris@0: Chris@0: /** Chris@14: * Passes alterable variables to deprecated hook_TYPE_alter() implementations. Chris@14: * Chris@14: * This method triggers an E_USER_DEPRECATED error if any implementations of Chris@14: * the alter hook are found. It is otherwise identical to alter(). Chris@14: * Chris@14: * See the documentation for alter() for more details. Chris@14: * Chris@14: * @param string $description Chris@14: * Helpful text describing what to do instead of implementing this alter Chris@14: * hook. Chris@14: * @param string|array $type Chris@14: * A string describing the type of the alterable $data. 'form', 'links', Chris@14: * 'node_content', and so on are several examples. Alternatively can be an Chris@14: * array, in which case hook_TYPE_alter() is invoked for each value in the Chris@14: * array, ordered first by module, and then for each module, in the order of Chris@14: * values in $type. For example, when Form API is using $this->alter() to Chris@14: * execute both hook_form_alter() and hook_form_FORM_ID_alter() Chris@14: * implementations, it passes array('form', 'form_' . $form_id) for $type. Chris@14: * @param mixed $data Chris@14: * The variable that will be passed to hook_TYPE_alter() implementations to be Chris@14: * altered. The type of this variable depends on the value of the $type Chris@14: * argument. For example, when altering a 'form', $data will be a structured Chris@14: * array. When altering a 'profile', $data will be an object. Chris@14: * @param mixed $context1 Chris@14: * (optional) An additional variable that is passed by reference. Chris@14: * @param mixed $context2 Chris@14: * (optional) An additional variable that is passed by reference. If more Chris@14: * context needs to be provided to implementations, then this should be an Chris@14: * associative array as described above. Chris@14: * Chris@14: * @see \Drupal\Core\Extension\ModuleHandlerInterface::alter() Chris@14: * @see https://www.drupal.org/core/deprecation#how-hook Chris@14: */ Chris@14: public function alterDeprecated($description, $type, &$data, &$context1 = NULL, &$context2 = NULL); Chris@14: Chris@14: /** Chris@0: * Returns an array of directories for all enabled modules. Useful for Chris@0: * tasks such as finding a file that exists in all module directories. Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function getModuleDirectories(); Chris@0: Chris@0: /** Chris@0: * Gets the human readable name of a given module. Chris@0: * Chris@0: * @param string $module Chris@0: * The machine name of the module which title should be shown. Chris@0: * Chris@0: * @return string Chris@0: * Returns the human readable name of the module or the machine name passed Chris@0: * in if no matching module is found. Chris@0: */ Chris@0: public function getName($module); Chris@0: Chris@0: }