You are here

function patterns_moduletags_filter in Patterns 7.2

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

Filters out information from a modulestag index and returns the results in a new array.

Select information based on the tag (e.g. node, vocabulary, etc.), or on the key (e.g. PATTERNS_CREATE), or on a combination of both.


array $moduletags Associative array of moduletags:

mixed $module (optional) Forces to return information only: from this module. Defaults NULL.

mixed $key (optional) Forces to return information only: from the modules containing this key. Defaults NULL.

Return value

array $tagmodules The filtered tagmodules array

1 call to patterns_moduletags_filter()
patterns_export_list_export_functions in patterns_export/patterns_export.module
Returns a list with the names of the components.


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


function patterns_moduletags_filter($moduletags, $module = NULL, $key = NULL) {
  if (empty($moduletags)) {
    return array();

  // Part of tag
  if (!empty($module) && !empty($key)) {
    foreach ($moduletags[$module] as $actions) {
      if (isset($actions[$key])) {
        return $actions[$key];

  // Full tag
  if (!empty($module)) {
    return $moduletags[$module];

  // All the values of key=$key from all tags
  if (!empty($key)) {
    $out = array();
    foreach ($moduletags as $module => $tag) {
      foreach ($tag as $actions) {
        if (isset($actions[$key])) {
          $out[$module] = $actions[$key];
    return $out;