Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybroomfield/487a0866d221fae4a9ccd8673da0d636 to your computer and use it in GitHub Desktop.
Save andybroomfield/487a0866d221fae4a9ccd8673da0d636 to your computer and use it in GitHub Desktop.
Patch for skiping over the tasty backend duplicate view if main tb manage content view does not exist yet (Fix install site from config)
diff --git a/src/TastyBackendManager.php b/src/TastyBackendManager.php
index 28bb212..a06c4c1 100644
--- a/src/TastyBackendManager.php
+++ b/src/TastyBackendManager.php
@@ -54,28 +54,31 @@ class TastyBackendManager extends SystemManager {
'plugin_id' => 'bundle',
'group' => 1,
];
-
+
// Duplicate the view.
- $view = \Drupal\views\Views::getView('tb_manage_content')->storage->createDuplicate();
-
- // Set some basic info.
- $view->setStatus(TRUE);
- $view->set('id', 'tb_manage_content_' . $type->id());
- $view->set('label', 'Tasty Backend Manage ' . $type->label());
- $view->set('description', 'Tasty Backend administration view to manage all ' . $type->label() . ' content.');
-
- // Set the display options.
- $display = $view->get('display');
- $display['default']['display_options']['access']['options']['perm'] = 'edit any ' . $type->id() . ' content';
- $display['default']['display_options']['filters']['type'] = $type_filter;
- $display['default']['display_options']['title'] = 'Manage ' . $type->label() . ' content';
- $display['page_1']['display_options']['path'] = 'admin/manage/content/' . $type->id();
- $display['page_1']['display_options']['menu']['title'] = $type->label();
- $display['page_1']['display_options']['menu']['description'] = 'Manage ' . $type->label() . ' content.';
- $view->set('display', $display);
-
- // Save the new view.
- $view->save();
+ $base_view = \Drupal\views\Views::getView('tb_manage_content');
+ if ($base_view) {
+ $view = $base_view->storage->createDuplicate();
+
+ // Set some basic info.
+ $view->setStatus(TRUE);
+ $view->set('id', 'tb_manage_content_' . $type->id());
+ $view->set('label', 'Tasty Backend Manage ' . $type->label());
+ $view->set('description', 'Tasty Backend administration view to manage all ' . $type->label() . ' content.');
+
+ // Set the display options.
+ $display = $view->get('display');
+ $display['default']['display_options']['access']['options']['perm'] = 'edit any ' . $type->id() . ' content';
+ $display['default']['display_options']['filters']['type'] = $type_filter;
+ $display['default']['display_options']['title'] = 'Manage ' . $type->label() . ' content';
+ $display['page_1']['display_options']['path'] = 'admin/manage/content/' . $type->id();
+ $display['page_1']['display_options']['menu']['title'] = $type->label();
+ $display['page_1']['display_options']['menu']['description'] = 'Manage ' . $type->label() . ' content.';
+ $view->set('display', $display);
+
+ // Save the new view.
+ $view->save();
+ }
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment