示例#1
0
 public function singleDiff($old_revision, Entity $new_revision)
 {
     // Get rid of extra indexes.
     if ($old_revision !== null) {
         $old_revision->cleanLoad();
         $new_revision->cleanLoad();
     } else {
         $new_revision->cleanNew();
     }
     // Run the entities through the resolver.
     if ($old_revision !== null) {
         $old_revision = clone $old_revision->definition;
     }
     $new_resolver = new Resolver($new_revision, false);
     $new_revision_object = clone $new_revision->definition;
     if ($old_revision !== null) {
         $old_revision_array = (array) $old_revision;
     } else {
         $old_revision_array = array();
     }
     $new_revision_array = (array) $new_revision_object;
     $additions = drupal_array_diff_assoc_recursive($new_revision_array, $old_revision_array);
     $deletions = $this->findToDelete($new_revision_array, $old_revision_array);
     // Pull in properties that don't support revisions on the node.
     $this->preserveUnchangingProperties($new_revision, $additions);
     // Resolve the additions.
     $new_resolver->resolveDependencies(false, $additions);
     $additions = $new_resolver->resolvedDefinition();
     return array('additions' => $additions, 'deletions' => $deletions);
 }