public DependencySerializationTrait::__sleep()
public function __sleep() { $this->_serviceIds = array(); $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value) && isset($value->_serviceId)) { // If a class member was instantiated by the dependency injection // container, only store its ID so it can be used to get a fresh object // on unserialization. $this->_serviceIds[$key] = $value->_serviceId; unset($vars[$key]); } // Special case the container, which might not have a service ID. elseif ($value instanceof ContainerInterface) { $this->_serviceIds[$key] = 'service_container'; unset($vars[$key]); } } return array_keys($vars); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!DependencyInjection!DependencySerializationTrait.php/function/DependencySerializationTrait::__sleep/8.1.x