public static function Views::delete in Hook Update Deploy Tools 7
Delete requested Views.
Parameters
mixed $views_names: string - a single machine name of a View to delete. array - an array of View machine names to delete.
Return value
string Message returned to display.
Throws
File
- src/
Views.php, line 53
Class
- Views
- Public methods for working with Views.
Namespace
HookUpdateDeployToolsCode
public static function delete($views_names = array()) {
$message = '';
$views_names = (array) $views_names;
if (count($views_names)) {
foreach ($views_names as $view_name) {
if ($view = views_get_view($view_name)) {
views_delete_view($view);
// Check if view was deleted.
if (views_get_view($view_name, TRUE)) {
// View still exists.
throw new HudtException('View @viewname still exists after being deleted. Possibly in code?', array(
'@viewname' => $view_name,
), WATCHDOG_ERROR, TRUE);
}
else {
// View successfully deleted.
$message .= Message::make('View @viewname successfully deleted', array(
'@viewname' => $view_name,
), WATCHDOG_INFO);
}
}
else {
// Output already deleted or not found message.
$message .= Message::make('View @viewname already deleted or could not be found.', array(
'@viewname' => $view_name,
), WATCHDOG_INFO);
}
}
}
return $message;
}