Unset references so that a $view object may be properly garbage collected.
public function destroy() {
foreach (array_keys($this->displayHandlers) as $display_id) {
if (isset($this->displayHandlers[$display_id])) {
$this->displayHandlers[$display_id]
->destroy();
unset($this->displayHandlers[$display_id]);
}
}
foreach ($this::viewsHandlerTypes() as $type => $info) {
if (isset($this->{$type})) {
$handlers =& $this->{$type};
foreach ($handlers as $id => $item) {
$handlers[$id]
->destroy();
}
unset($handlers);
}
}
if (isset($this->style_plugin)) {
$this->style_plugin
->destroy();
}
$keys = array(
'current_display',
'display_handler',
'displayHandlers',
'field',
'argument',
'filter',
'sort',
'relationship',
'header',
'footer',
'empty',
'query',
'result',
'inited',
'style_plugin',
'plugin_name',
'exposed_data',
'exposed_input',
'many_to_one_tables',
);
foreach ($keys as $key) {
unset($this->{$key});
}
// These keys are checked by the next init, so instead of unsetting them,
// just set the default values.
$keys = array(
'items_per_page',
'offset',
'current_page',
);
foreach ($keys as $key) {
if (isset($this->{$key})) {
$this->{$key} = NULL;
}
}
$this->built = $this->executed = FALSE;
$this->build_info = array();
$this->attachment_before = '';
$this->attachment_after = '';
}