Same name and namespace in other branches
  1. 5.0.x advagg.module \advagg_hooks_implemented() 1 commentaire
  2. 7.x-2.x advagg.module \advagg_hooks_implemented() 1 commentaire
  3. 8.x-3.x advagg.module \advagg_hooks_implemented() 1 commentaire
  4. 8.x-4.x advagg.module \advagg_hooks_implemented() 1 commentaire

Get back what hooks are implemented.

Paramètres

bool $all: If TRUE get all hooks related to css/js files. if FALSE get only the subset of hooks that alter the filename/contents.

Return value

array List of hooks and what modules have implemented them.

2 calls to advagg_hooks_implemented()
advagg_current_hooks_hash_array dans ./advagg.module
Get an array of all hooks and settings that affect aggregated files contents.
InfoForm::buildForm dans src/Form/InfoForm.php

Fichier

./advagg.module, line 471

Code

function advagg_hooks_implemented($all = TRUE) {
    $hooks =& drupal_static(__FUNCTION__);
    if ($hooks) {
        return $hooks;
    }
    $module_handler = \Drupal::moduleHandler();
    // Get hooks in use.
    $hooks = [
        'advagg_aggregate_grouping_alter' => [],
        'advagg_css_contents_alter' => [],
        'advagg_js_contents_alter' => [],
        'advagg_current_hooks_hash_array_alter' => [],
        'advagg_hooks_implemented' => [],
    ];
    if ($all) {
        $hooks += [
            'js_alter' => [],
            'css_alter' => [],
        ];
    }
    // Call hook_advagg_hooks_implemented_alter().
    $module_handler->alter('advagg_hooks_implemented', $hooks, $all);
    // Cache module_implements as this will load up .inc files.
    $serialize_function = advagg_get_serializer();
    $cid = 'advagg_hooks_implemented:' . (int) $all . ':' . Crypt::hashBase64($serialize_function($hooks));
    $cache = \Drupal::cache('bootstrap')->get($cid);
    if (!empty($cache->data)) {
        $hooks = $cache->data;
    }
    else {
        foreach ($hooks as $hook => $values) {
            $hooks[$hook] = $module_handler->getImplementations($hook);
            // Also check themes as drupal_alter() allows for themes to alter things.
            $theme_keys = \Drupal::service('theme_handler')->listInfo();
            if (!empty($theme_keys)) {
                foreach ($theme_keys as $theme_key => $info) {
                    $function = $theme_key . '_' . $hook;
                    if (function_exists($function)) {
                        $hooks[$hook][] = $info['name'];
                    }
                }
            }
        }
        \Drupal::cache('bootstrap')->set($cid, $hooks, REQUEST_TIME + 600);
    }
    return $hooks;
}