You are here

function patterns_tagmodules_get_index in Patterns 7.2

Same name and namespace in other branches
  1. 7 includes/ \patterns_tagmodules_get_index()

Builds an associative array of tags and modules (components).

Invokes hook_patterns on all modules, and returns an index of available tags and information associated with them (e.g. from which module they are handled).

The index is cached, but reloading can be forced.


array $data (optional) An associative array of data, that the: components can use to build dynamic forms names. Defaults NULL. The array usually corresponds to an action in a pattern file, e.g.

array('tag' => 'node', 'type' => 'article', 'title' => 'Test Article', 'body', => 'lorem ipsum ...', );

bool $reset If TRUE, forces rebuilding the index from all: the components. Defaults FALSE

bool $reload_components (optional) If TRUE, forces reloading: the Patterns components from file system

Return value

array $tagmodules Index of tag and modules

See also


7 calls to patterns_tagmodules_get_index()
PatternsIndexesTestCase::testTagmodules in tests/indexes/indexes.test
patterns_export_page1 in patterns_export/patterns_export.module
patterns_implement_action in includes/core/
Setup and run an action.
patterns_invoke in ./patterns.module
Execute hook_patterns with the given operation and return the results.
patterns_prepare_action in includes/core/
Preparing and validating the action tags as they are written in the pattern file. Concretely, it invokes operations 'prepare', and 'validate' on the pattern component.

... See full list


includes/, line 40
Functions related to build and retrieve information from the *tagmodules* and *moduletags* indexes.


function patterns_tagmodules_get_index($data = NULL, $reset = FALSE, $reload_components = FALSE) {
  $tagmodules =& drupal_static(__FUNCTION__);
  if ($reload_components) {

  // Index not yet built or forced rebuilt
  if ($reset || empty($tagmodules)) {
    $tagmodules = array();

    // Get a list of tags and their modules.
    foreach (module_implements('patterns') as $module) {
      _patterns_tagmodules_add_module($module, $tagmodules, $data);
  elseif (!empty($data)) {
    $module = patterns_tagmodules_find_module($data, $tagmodules);
    _patterns_tagmodules_add_module($module, $tagmodules, $data);

  // All values from all tags
  return $tagmodules;