Pimcore\Model\Object\AbstractObject::__sleep PHP Method

__sleep() public method

public __sleep ( )
    public function __sleep()
    {
        $finalVars = [];
        $parentVars = parent::__sleep();
        if (isset($this->_fulldump)) {
            // this is if we want to make a full dump of the object (eg. for a new version), including childs for recyclebin
            $blockedVars = ["o_userPermissions", "o_dependencies", "o_hasChilds", "o_versions", "o_class", "scheduledTasks", "o_parent", "omitMandatoryCheck"];
            $finalVars[] = "_fulldump";
            $this->removeInheritedProperties();
        } else {
            // this is if we want to cache the object
            $blockedVars = ["o_userPermissions", "o_dependencies", "o_childs", "o_hasChilds", "o_versions", "o_class", "scheduledTasks", "o_properties", "o_parent", "o___loadedLazyFields", "omitMandatoryCheck"];
        }
        foreach ($parentVars as $key) {
            if (!in_array($key, $blockedVars)) {
                $finalVars[] = $key;
            }
        }
        return $finalVars;
    }

Usage Example

Example #1
0
 /**
  *
  */
 public function __sleep()
 {
     $parentVars = parent::__sleep();
     $finalVars = array();
     $lazyLoadedFields = $this->getLazyLoadedFields();
     foreach ($parentVars as $key) {
         if (in_array($key, $lazyLoadedFields)) {
             // prevent lazyloading properties to go into the cache, only to version and recyclebin, ... (_fulldump)
             if (isset($this->_fulldump)) {
                 $finalVars[] = $key;
             }
         } else {
             $finalVars[] = $key;
         }
     }
     return $finalVars;
 }