You are here

public function EntityBrowser::__sleep in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Entity/EntityBrowser.php \Drupal\entity_browser\Entity\EntityBrowser::__sleep()

Sleep method.

Prevents plugin collections from being serialized and correctly serializes selected entities.

Overrides ConfigEntityBase::__sleep

File

src/Entity/EntityBrowser.php, line 428

Class

EntityBrowser
Defines an entity browser configuration entity.

Namespace

Drupal\entity_browser\Entity

Code

public function __sleep() {

  // Save configuration for all plugins.
  $this->widgets = $this
    ->getWidgets()
    ->getConfiguration();
  $this->widget_selector_configuration = $this
    ->widgetSelectorPluginCollection()
    ->getConfiguration();
  $this->display_configuration = $this
    ->displayPluginCollection()
    ->getConfiguration();
  $this->selection_display_configuration = $this
    ->selectionDisplayPluginCollection()
    ->getConfiguration();
  return array_diff(array_keys(get_object_vars($this)), [
    'widgetsCollection',
    'widgetSelectorCollection',
    'displayCollection',
    'selectionDisplayCollection',
    'selectedEntities',
  ]);
}