8.3.x ConfigEntityBase.php public ConfigEntityBase::__sleep()
8.0.x ConfigEntityBase.php public ConfigEntityBase::__sleep()
8.1.x ConfigEntityBase.php public ConfigEntityBase::__sleep()
8.2.x ConfigEntityBase.php public ConfigEntityBase::__sleep()
8.4.x ConfigEntityBase.php public ConfigEntityBase::__sleep()

Overrides Entity::__sleep

1 call to ConfigEntityBase::__sleep()
View::__sleep in core/modules/views/src/Entity/View.php
4 methods override ConfigEntityBase::__sleep()
EntityDisplayBase::__sleep in core/lib/Drupal/Core/Entity/EntityDisplayBase.php
FieldConfigBase::__sleep in core/lib/Drupal/Core/Field/FieldConfigBase.php
Implements the magic __sleep() method.
FieldStorageConfig::__sleep in core/modules/field/src/Entity/FieldStorageConfig.php
Implements the magic __sleep() method.
View::__sleep in core/modules/views/src/Entity/View.php

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php, line 353

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

public function __sleep() {
  $keys_to_unset = [];
  if ($this instanceof EntityWithPluginCollectionInterface) {
    $vars = get_object_vars($this);
    foreach ($this->getPluginCollections() as $plugin_config_key => $plugin_collection) {
      // Save any changes to the plugin configuration to the entity.
      $this->set($plugin_config_key, $plugin_collection->getConfiguration());
      // If the plugin collections are stored as properties on the entity,
      // mark them to be unset.
      $keys_to_unset += array_filter($vars, function($value) use ($plugin_collection) {
        return $plugin_collection === $value;
      });
    }
  }

  $vars = parent::__sleep();

  if (!empty($keys_to_unset)) {
    $vars = array_diff($vars, array_keys($keys_to_unset));
  }
  return $vars;
}