Skip to content

Instantly share code, notes, and snippets.

@damiankloip
Created September 21, 2012 09:54
Show Gist options
  • Save damiankloip/3760690 to your computer and use it in GitHub Desktop.
Save damiankloip/3760690 to your computer and use it in GitHub Desktop.
diff --git a/lib/Drupal/views/ViewStorageController.php b/lib/Drupal/views/ViewStorageController.php
index 744157c..43215ba 100644
--- a/lib/Drupal/views/ViewStorageController.php
+++ b/lib/Drupal/views/ViewStorageController.php
@@ -56,87 +56,12 @@ class ViewStorageController extends ConfigStorageController {
}
/**
- * Overrides Drupal\config\ConfigStorageController::save().
- *
- * This currently replaces the reflection code with a static array of
- * properties to be set on the config object. This can be removed when the
- * view storage is isolated so the ReflectionClass can work.
+ * Overrides Drupal\config\ConfigStorageController::postSave().
*/
- public function save(EntityInterface $entity) {
- $prefix = $this->entityInfo['config prefix'] . '.';
-
- // Load the stored entity, if any, and rename it.
- if ($entity->getOriginalID()) {
- $id = $entity->getOriginalID();
- }
- else {
- $id = $entity->id();
- }
- $config = config($prefix . $id);
- $config->setName($prefix . $entity->id());
-
- if (!$config->isNew() && !isset($entity->original)) {
- $entity->original = entity_load_unchanged($this->entityType, $id);
- }
-
- $this->preSave($entity);
- $this->invokeHook('presave', $entity);
-
- // @todo This temp measure will be removed once we have a better way or
- // separation of storage and the executed view.
- $config_properties = array (
- 'disabled',
- 'api_version',
- 'name',
- 'description',
- 'tag',
- 'base_table',
- 'human_name',
- 'core',
- 'display',
- 'uuid',
- 'module',
- );
-
- foreach ($config_properties as $property) {
- if ($property == 'display') {
- $displays = array();
- foreach ($entity->display as $key => $display) {
- $displays[$key] = array(
- 'display_options' => $display->display_options,
- 'display_plugin' => $display->display_plugin,
- 'id' => $display->id,
- 'display_title' => $display->display_title,
- 'position' => isset($display->position) ? $display->position : 0,
- );
- }
- $config->set('display', $displays);
- }
- else {
- $config->set($property, $entity->$property);
- }
- }
-
- if (!$config->isNew()) {
- $return = SAVED_NEW;
- $config->save();
- $this->postSave($entity, TRUE);
- $this->invokeHook('update', $entity);
- }
- else {
- $return = SAVED_UPDATED;
- $config->save();
- $entity->enforceIsNew(FALSE);
- $this->postSave($entity, FALSE);
- $this->invokeHook('insert', $entity);
- }
-
+ public function postSave(EntityInterface $entity, $update) {
+ parent::postSave($entity, $update);
// Clear caches.
views_invalidate_cache();
-
- unset($entity->original);
-
- return $return;
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment