/** * Cache key for last revision * * @param AbstractRevision $revision * @return string */ protected function getLastRevCacheKey(AbstractRevision $revision) { return $revision->getCollectionId()->getAlphadecimal() . '-' . $revision->getRevisionType() . '-last-rev'; }
protected function expandReferences(Workflow $workflow, AbstractRevision $revision, array $references) { $referenceObjs = array(); $factory = new ReferenceFactory($workflow, $revision->getRevisionType(), $revision->getCollectionId()); foreach ($references as $ref) { $referenceObjs[] = $factory->{$ref['factoryMethod']}($ref['refType'], $ref['value']); } return $referenceObjs; }
/** * Instantiate a new object based off of an AbstractRevision object. * * @param AbstractRevision $revision * @return AbstractCollection */ public static function newFromRevision(AbstractRevision $revision) { return static::newFromId($revision->getCollectionId()); }
/** * @param AbstractRevision $obj * @return string[] */ public static function toStorageRow($obj) { return array('rev_id' => $obj->revId->getAlphadecimal(), 'rev_user_id' => $obj->user->id, 'rev_user_ip' => $obj->user->ip, 'rev_user_wiki' => $obj->user->wiki, 'rev_parent_id' => $obj->prevRevision ? $obj->prevRevision->getAlphadecimal() : null, 'rev_change_type' => $obj->changeType, 'rev_type' => $obj->getRevisionType(), 'rev_type_id' => $obj->getCollectionId()->getAlphadecimal(), 'rev_content' => $obj->content, 'rev_content_url' => $obj->contentUrl, 'rev_flags' => implode(',', $obj->flags), 'rev_mod_state' => $obj->moderationState, 'rev_mod_user_id' => $obj->moderatedBy ? $obj->moderatedBy->id : null, 'rev_mod_user_ip' => $obj->moderatedBy ? $obj->moderatedBy->ip : null, 'rev_mod_user_wiki' => $obj->moderatedBy ? $obj->moderatedBy->wiki : null, 'rev_mod_timestamp' => $obj->moderationTimestamp, 'rev_mod_reason' => $obj->moderatedReason, 'rev_last_edit_id' => $obj->lastEditId ? $obj->lastEditId->getAlphadecimal() : null, 'rev_edit_user_id' => $obj->lastEditUser ? $obj->lastEditUser->id : null, 'rev_edit_user_ip' => $obj->lastEditUser ? $obj->lastEditUser->ip : null, 'rev_edit_user_wiki' => $obj->lastEditUser ? $obj->lastEditUser->wiki : null, 'rev_content_length' => $obj->contentLength, 'rev_previous_content_length' => $obj->previousContentLength); }
public function isComparable(AbstractRevision $cur, AbstractRevision $prev) { if ($cur->getRevisionType() == $prev->getRevisionType()) { return $cur->getCollectionId()->equals($prev->getCollectionId()); } else { return false; } }
/** * Compares the references contained within $revision against those stored for * that revision. Returns the differences. * * @param Workflow $workflow * @param AbstractRevision $revision * @param PostRevision|null $root * @return array Two nested arrays, first the references that were added and * second the references that were removed. */ protected function calculateChangesFromExisting(Workflow $workflow, AbstractRevision $revision, PostRevision $root = null) { $prevReferences = $this->getExistingReferences($revision->getRevisionType(), $revision->getCollectionId()); $references = $this->getReferencesFromRevisionContent($workflow, $revision, $root); return $this->referencesDifference($prevReferences, $references); }
/** * Retrieves the current revision for a given AbstractRevision * @param AbstractRevision $revision The revision to retrieve the current revision for. * @return AbstractRevision|null AbstractRevision of the current revision. */ protected function getCurrentRevision(AbstractRevision $revision) { $collectionId = $revision->getCollectionId(); if (!isset($this->currentRevisionsCache[$collectionId->getAlphadecimal()])) { $currentRevision = $revision->getCollection()->getLastRevision(); $this->currentRevisionsCache[$collectionId->getAlphadecimal()] = $currentRevision->getRevisionId(); $this->revisionCache[$currentRevision->getRevisionId()->getAlphadecimal()] = $currentRevision; } $currentRevisionId = $this->currentRevisionsCache[$collectionId->getAlphadecimal()]; return $this->revisionCache[$currentRevisionId->getAlphaDecimal()]; }