Created
November 12, 2017 21:32
-
-
Save ahebrank/78e59b50763d4c34f595d69fc47708b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/Plugin/views/display/Eva.php b/src/Plugin/views/display/Eva.php | |
| index 6adb305..0fa8c30 100644 | |
| --- a/src/Plugin/views/display/Eva.php | |
| +++ b/src/Plugin/views/display/Eva.php | |
| @@ -205,10 +205,34 @@ class Eva extends DisplayPluginBase { | |
| } | |
| public function remove() { | |
| - // clean up display configs before the display disappears | |
| - $longname = $this->view->storage->get('id') . '_' . $this->display['id']; | |
| + $view_id = $this->view->storage->get('id'); | |
| + | |
| + // clean up view and display configs before the display disappears | |
| + $longname = $view_id . '_' . $this->display['id']; | |
| _eva_clear_detached($longname); | |
| + // check the view config -- if there are no longer any Evas, remove the dependency | |
| + $cf = \Drupal::configFactory(); | |
| + $config = $cf->getEditable('views.view.' . $view_id); | |
| + $config_data = $config->get(); | |
| + $eva_count = 0; | |
| + foreach ($config_data['display'] as $display_id => $display) { | |
| + // ignore -- this one is getting removed anyway | |
| + if ($display_id == $this->display['id']) { | |
| + continue; | |
| + } | |
| + // there's another display that's still using Eva | |
| + if ($display['display_plugin'] == 'entity_view') { | |
| + $eva_count += 1; | |
| + } | |
| + } | |
| + // no Eva's? Remove the dependency | |
| + if ($eva_count == 0) { | |
| + unset($config_data['dependencies']['module']['eva']); | |
| + $config->setData($config_data); | |
| + $config->save(); | |
| + } | |
| + | |
| parent::remove(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment