Example #1
0
 /** {@inheritDoc} */
 public function compute(AbstractSnapshot $old, AbstractSnapshot $new)
 {
     if (null !== $this->changes) {
         return;
     }
     $this->changes = [];
     foreach (array_unique(array_merge(array_keys($old->getComparableData()), array_keys($new->getComparableData()))) as $key) {
         $result = $this->computeEntry($old, $new, $key);
         if (null !== $result) {
             $this->changes[$key] = $result;
         }
     }
     /*
      * Collection tricky case : each changes should not be represented by
      * its primary key, but by a numeric key. Because it is a collection, duh.
      */
     if ($old instanceof CollectionSnapshot && $new instanceof CollectionSnapshot) {
         $this->changes = array_values($this->changes);
     }
 }