function environment_allowed in Environment 7
Same name and namespace in other branches
- 6 environment.module \environment_allowed()
Check if something is allowed in the current environment.
Parameters
string $name: Name of the thing to check if allowed, eg. function.
string $category: Optional; category of the thing to check for, eg. name of module. Defaults to 'other'.
bool $default: Optional; what the default should be if no environment value is found. Defaults to FALSE.
string $workflow: Optional; specify the workflow state to check for allowance.
Return value
bool TRUE or FALSE for whether the thing is allowed.
File
- ./
environment.module, line 86 - Module for handling changes in server environments
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;
}