- * {@inheritdoc}
- */
- public function serialize() {
- return serialize([
- // Only serialize the storage entity ID.
- $this->storage->id(),
- $this->current_display,
- $this->args,
- $this->current_page,
- $this->exposed_input,
- $this->exposed_raw_input,
- $this->exposed_data,
- $this->dom_id,
- $this->executed,
- ]);
+ * Magic method implementation to serialize the view executable.
+ *
+ * @return array
+ * The names of all variables that should be serialized.
+ */
+ public function __sleep() {
+ // Limit to only the required data which is needed to properly restore the
+ // state during unserialization.
+ $this->serializationData = [
+ 'storage' => $this->storage->id(),
+ 'views_data' => $this->viewsData->_serviceId,
+ 'route_provider' => $this->routeProvider->_serviceId,
+ 'current_display' => $this->current_display,
+ 'args' => $this->args,
+ 'current_page' => $this->current_page,
+ 'exposed_input' => $this->exposed_input,
+ 'exposed_raw_input' => $this->exposed_raw_input,
+ 'exposed_data' => $this->exposed_data,
+ 'dom_id' => $this->dom_id,
+ 'executed' => $this->executed,
+ ];
+ return ['serializationData'];