function environment_allowed in Environment 6
Same name and namespace in other branches
- 7 environment.module \environment_allowed()
Check if something is allowed in the current environment.
Parameters
$name: Name of the thing to check if allowed, eg. function.
$category: Optional; category of the thing to check for, eg. name of module. Defaults to 'other'.
$default: Optional; what the default should be if no environment value is found. Defaults to FALSE.
$workflow: Optional; specify the workflow state to check for allowance.
Return value
TRUE or FALSE for whether the thing is allowed.
File
- ./
environment.module, line 96
Code
function environment_allowed($name, $category = 'other', $default = FALSE, $workflow = 'default') {
$env = environment_current($workflow, NULL, TRUE);
if (!empty($env)) {
if (!empty($env[$category])) {
if (isset($env[$category][$name])) {
$result = $env[$category][$name];
}
elseif (isset($env[$category]['default'])) {
$result = $env[$category]['default'];
}
}
if (!isset($result) && isset($env['default'])) {
$result = $env['default'];
}
}
if (!isset($result)) {
$result = $default;
}
return $result;
}