Ejemplo n.º 1
0
 /**
  * Create a new revision object for the provided EPRevisionedObject.
  * The EPRevisionedObject should have all it's fields loaded.
  *
  * @since 0.1
  *
  * @param EPDBObject $object
  * @param EPRevisionAction $revAction
  *
  * @return EPRevision
  */
 public static function newFromObject(EPRevisionedObject $object, EPRevisionAction $revAction)
 {
     $fields = array('object_id' => $object->getId(), 'user_id' => $revAction->getUser()->getID(), 'user_text' => $revAction->getUser()->getName(), 'type' => get_class($object), 'comment' => $revAction->getComment(), 'minor_edit' => $revAction->isMinor(), 'time' => $revAction->getTime(), 'deleted' => $revAction->isDelete(), 'data' => serialize($object->toArray()));
     $identifier = $object->getIdentifier();
     if (!is_null($identifier)) {
         $fields['object_identifier'] = $identifier;
     }
     return new static($fields);
 }
Ejemplo n.º 2
0
 /**
  * Return if any fields got changed.
  * 
  * @since 0.1
  * 
  * @param EPRevisionedObject $revision
  * @param boolean $excludeSummaryFields When set to true, summaty field changes are ignored.
  * 
  * @return boolean
  */
 protected function fieldsChanged(EPRevisionedObject $revision, $excludeSummaryFields = false)
 {
     foreach ($this->fields as $name => $value) {
         $excluded = $excludeSummaryFields && in_array($name, $this->getSummaryFields());
         if (!$excluded && $revision->getField($name) !== $value) {
             return true;
         }
     }
     return false;
 }