You are here

function flag_load in Flag 7.3

Same name and namespace in other branches
  1. 6.2 flag.module \flag_load()
  2. 7.2 flag.module \flag_load()

Menu loader for '%flag' arguments.

Parameters

string $flag_name: The machine name of the flag.

bool $include_disabled: (optional) Whether to return a disabled flag too. Normally only enabled flags are returned. Some menu items operate on disabled flags and in this case you need to turn on this switch by doing:


  'load arguments' => array(TRUE)
  

in your hook_menu().

Return value

Either the flag object, or FALSE if none was found.

3 calls to flag_load()
flag_export_flags in includes/flag.export.inc
Export a flag to code.
flag_features_export in includes/flag.features.inc
Implements hook_features_export().
flag_features_revert in includes/flag.features.inc
Implements hook_features_revert().

File

./flag.module, line 391
The Flag module.

Code

function flag_load($flag_name, $include_disabled = FALSE) {
  if ($flag = flag_get_flag($flag_name)) {
    return $flag;
  }
  else {

    // No enabled flag was found. Search among the disabled ones.
    if ($include_disabled) {
      $default_flags = flag_get_default_flags(TRUE);
      if (isset($default_flags[$flag_name])) {
        return $default_flags[$flag_name];
      }
    }
  }

  // A menu loader has to return FALSE (not NULL) when no object is found.
  return FALSE;
}