/** * Serializes the object as an associative array, which can be passed * to newFromArray to create a new instance. * * @since 0.1 * * @return array */ public function toArray() { $changeSet = array('id' => $this->id, 'user_name' => $this->edit->getUserName(), 'page_id' => $this->edit->getPageID(), 'time' => $this->edit->getTime(), 'editid' => $this->edit->getId(), 'changes' => array()); foreach ($this->getAllProperties() as $property) { $propChanges = array(); foreach ($this->getAllPropertyChanges($property) as $change) { $propChange = array(); if (is_object($change->getOldValue())) { $propChange['old'] = $change->getOldValue()->getSerialization(); } if (is_object($change->getNewValue())) { $propChange['new'] = $change->getNewValue()->getSerialization(); } $propChanges[] = $propChange; } $changeSet['changes'][$property->getSerialization()] = $propChanges; } return $changeSet; }