1 views.module views_get_view($name, $reset = FALSE)

Get a view from the database or from default views.

This function is just a static wrapper around views::load(). This function isn't called 'views_load()' primarily because it might get a view from the default views which aren't technically loaded from the database.

Parameters

$name: The name of the view.

$reset: If TRUE, reset this entry in the load cache.

Return value

view: A reference to the $view object. Use $reset if you're sure you want a fresh one.

File

core/modules/views/views.module, line 1445
Primarily Backdrop hooks and global API functions to manipulate views.

Code

function views_get_view($name, $reset = FALSE) {
  $cache = &backdrop_static(__FUNCTION__, array());

  if ($reset || !isset($cache[$name])) {
    if ($view_data = config('views.view.' . $name)->get()) {
      $cache[$name] = new view($view_data);
    }
    else {
      $cache[$name] = FALSE;
    }
  }

  $return = FALSE;
  if ($cache[$name]) {
    $return = $cache[$name]->clone_view();
  }

  return $return;
}