public static function Contexts::disable in Hook Update Deploy Tools 7
Disables an array of contexts and checks to make sure they were disabled.
Parameters
mixed $contexts: array: of context machine names to disable. string: single context machine name to disable
Return value
string Messsage indicating the contexts are disabled.
File
- src/
Contexts.php, line 166
Class
- Contexts
- Public method for managing Contexts that verifies the changes.
Namespace
HookUpdateDeployToolsCode
public static function disable($contexts = array(), $disable_dependents = TRUE) {
try {
$contexts = (array) $contexts;
self::canSwitch();
// If a context is missing, technically it is already disabled, so there
// is no need for this to be a strict check.
self::checkContextsExist($contexts, FALSE);
foreach ($contexts as $context) {
$context_object = context_load($context);
ctools_export_crud_disable('context', $context_object);
}
// Verify that the contexts were disabled.
$success = self::checkDisabled($contexts);
return $success;
} catch (\Exception $e) {
$vars['!error'] = method_exists($e, 'logMessage') ? $e
->logMessage() : $e
->getMessage();
if (!method_exists($e, 'logMessage')) {
// Not logged yet, so log it.
$message = 'contexts::disable failed because: !error';
Message::make($message, $vars, WATCHDOG_ERROR);
}
throw new HudtException('Update aborted! !error', $vars, WATCHDOG_ERROR, FALSE);
}
}