You are here

function skinr_invoke_all in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr.module \skinr_invoke_all()

Invoke a hook in all enabled modules and themes that implement it.

Replacement for ModuleHandler::invokeAll() that only invokes modules that implement the current version of Skinr API. It also supports $module.skinr.inc files in themes and custom paths.

Parameters

$hook: The name of the hook to invoke.

...: Arguments to pass to the hook.

Return value

An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array.

15 calls to skinr_invoke_all()
Skin::elementLabel in src/Entity/Skin.php
Returns the element label.
SkinEditForm::elementOptions in skinr_ui/src/Form/SkinEditForm.php
Return an array of element options for a module.
SkinrApiTest::testSkinrInvokeAll in src/Tests/SkinrApiTest.php
Test that module_invoke_all() can load a hook defined in hook_hook_info().
SkinrApiTestCase::testSkinrInvokeAll in src/Tests/skinr.test
Test that module_invoke_all() can load a hook defined in hook_hook_info().
SkinrPanelsTestCase::testPanelsDatabase in skinr_panels/tests/skinr_panels.test
Tests panels plugin.

... See full list

File

./skinr.module, line 599
Handles core Skinr functionality.

Code

function skinr_invoke_all($hook) {
  $args = func_get_args();

  // Remove $hook from the arguments.
  unset($args[0]);
  $return = array();
  foreach (skinr_implements($hook) as $module) {
    $function = $module . '_' . $hook;
    if (function_exists($function)) {
      $result = call_user_func_array($function, $args);
      if (isset($result) && is_array($result)) {
        $return = array_merge_recursive($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
  }
  return $return;
}