From ec2a95056326dfcb68d85767a88e4c4a99126a7c Mon Sep 17 00:00:00 2001
From: Daniel Wehner <daniel.wehner@erdfisch.de>
Date: Sun, 26 Aug 2012 23:25:31 +0200
Subject: [PATCH] Override CTools callback to load view objects via the entity
 controller.

---
 views.install |  3 +++
 views.module  | 24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/views.install b/views.install
index dd6c8bf9e453..826d98d3ec08 100644
--- a/views.install
+++ b/views.install
@@ -35,6 +35,9 @@ function views_schema() {
       ),
       'object' => 'Drupal\views\View',
       // the callback to load the displays
+      'load all callback' => 'views_get_all_views',
+      'load callback' => 'views_storage_load',
+      'save callback' => 'views_storage_save',
       'subrecords callback' => 'views_load_display_records',
       // the variable that holds enabled/disabled status
       'status' => 'views_defaults',
diff --git a/views.module b/views.module
index 930b100309bd..5d13a6317894 100644
--- a/views.module
+++ b/views.module
@@ -1572,8 +1572,28 @@ function views_get_applicable_views($type) {
  */
 function views_get_all_views($reset = FALSE) {
   // @todo replace with http://drupal.org/node/1741154.
-  ctools_include('export');
-  return ctools_export_crud_load_all('views_view', $reset);
+  $controller = entity_get_controller('view');
+  return $controller->load();
+}
+
+/**
+ * Loads a view with the storage controller.
+ *
+ * @param string $id
+ *   The view name to load.
+ *
+ * @return Drupal\views\View
+ *   The view which is loaded.
+ */
+function views_storage_load($id) {
+  $controller = entity_get_controller('view');
+  $result = $controller->load(array($id));
+  return reset($result);
+}
+
+function views_storage_save(View $view) {
+  $controller = entity_get_controller('view');
+  return $controller->save($view);
 }
 
 /**
-- 
GitLab