Beispiel #1
0
 /**
  * Calculate revision diff
  *
  * @param array $requestedRevisions
  * @return array
  */
 public function calculateRevisionDiff(array $requestedRevisions)
 {
     $missingRevisions = array();
     foreach ($requestedRevisions as $documentId => $revisions) {
         $missingRevisions[$documentId] = $this->revisionDiffer->calculate($revisions, isset($this->data[$documentId]) ? array_keys($this->data[$documentId]) : array());
     }
     return array_filter($missingRevisions);
 }
Beispiel #2
0
 /**
  * Calculate revision diff
  *
  * Returns an array of revisions for each document which are not in the
  * database yet.
  *
  * @param array $requestedRevisions
  * @return array
  */
 public function calculateRevisionDiff(array $requestedRevisions)
 {
     $result = $this->database->query("SELECT\n                d_id id,\n                d_revision revision\n            FROM\n                document\n            WHERE\n                d_id IN (" . implode(', ', array_map(array($this->database, 'quote'), array_keys($requestedRevisions))) . ");")->fetchAll();
     $availableRevisions = array();
     foreach ($result as $row) {
         if (!isset($availableRevisions[$row['id']])) {
             $availableRevisions[$row['id']] = array();
         }
         $availableRevisions[$row['id']][] = $row['revision'];
     }
     $missingRevisions = array();
     foreach ($requestedRevisions as $documentId => $revisions) {
         $missingRevisions[$documentId] = $this->revisionDiffer->calculate($revisions, isset($availableRevisions[$documentId]) ? $availableRevisions[$documentId] : array());
     }
     return array_filter($missingRevisions);
 }