function BlockDisplayVariant::__sleep

Same name in other branches
  1. 8.x-3.x src/Plugin/DisplayVariant/BlockDisplayVariant.php \Drupal\ctools\Plugin\DisplayVariant\BlockDisplayVariant::__sleep()

File

src/Plugin/DisplayVariant/BlockDisplayVariant.php, line 204

Class

BlockDisplayVariant
Provides a base class for a display variant that simply contains blocks.

Namespace

Drupal\ctools\Plugin\DisplayVariant

Code

public function __sleep() {
    $vars = parent::__sleep();
    // Gathered contexts objects should not be serialized.
    if (($key = array_search('contexts', $vars)) !== FALSE) {
        unset($vars[$key]);
    }
    // The block plugin collection should also not be serialized, ensure that
    // configuration is synced back.
    if (($key = array_search('blockPluginCollection', $vars)) !== FALSE) {
        if ($this->blockPluginCollection) {
            $this->configuration['blocks'] = $this->blockPluginCollection
                ->getConfiguration();
        }
        unset($vars[$key]);
    }
    return $vars;
}