tsAdded = time(); // default } /** Load data from basic class to prevent issues when class definitions changes over time */ public function fromClass($object) { foreach($object as $property => $value) { if ($property == 'customImprovement') { continue; } if (property_exists($this, $property)) { $this->$property = $value; } } } /** Save data as basic class to prevent issues when class definitions changes over time */ public function toClass() { $class = new \stdClass; $vars = get_object_vars($this); foreach($vars as $property => $value) // only used by media library. { if ($property == 'customImprovement') { continue; } if ($property == 'convertMeta' && is_null($this->convertMeta)) { continue; } elseif ($property == 'convertMeta') { $class->$property = $this->$property->toClass(); continue; } // if (is_null($value)) // don't save default / values without init. // continue; $class->$property = $this->$property; } return $class; } }