getDeleteDiff() public method

INTERNAL: getDeleteDiff
public getDeleteDiff ( ) : array
return array
 /**
  * {@inheritdoc}
  */
 public function getDeleteDiff()
 {
     return $this->collection->getDeleteDiff();
 }
 /**
  * Deletes removed elements from a PersistentCollection instance.
  *
  * This method is intended to be used with the "pushAll" and "addToSet"
  * strategies.
  *
  * @param PersistentCollection $coll
  * @param array $options
  */
 private function deleteElements(PersistentCollection $coll, array $options)
 {
     $deleteDiff = $coll->getDeleteDiff();
     if (empty($deleteDiff)) {
         return;
     }
     list($propertyPath, $parent) = $this->getPathAndParent($coll);
     $query = array('$unset' => array());
     foreach ($deleteDiff as $key => $document) {
         $query['$unset'][$propertyPath . '.' . $key] = true;
     }
     $this->executeQuery($parent, $query, $options);
     /**
      * @todo This is a hack right now because we don't have a proper way to
      * remove an element from an array by its key. Unsetting the key results
      * in the element being left in the array as null so we have to pull
      * null values.
      */
     $this->executeQuery($parent, array('$pull' => array($propertyPath => null)), $options);
 }
Beispiel #3
0
 /**
  * Deletes removed rows from a PersistentCollection instance.
  *
  * @param PersistentCollection $coll
  * @param array $options
  */
 private function deleteRows(PersistentCollection $coll, array $options)
 {
     $deleteDiff = $coll->getDeleteDiff();
     if ($deleteDiff) {
         list($propertyPath, $parent) = $this->getPathAndParent($coll);
         $query = array($this->cmd . 'unset' => array());
         foreach ($deleteDiff as $key => $document) {
             $query[$this->cmd . 'unset'][$propertyPath . '.' . $key] = true;
         }
         $this->executeQuery($parent, $query, $options);
         /**
          * @todo This is a hack right now because we don't have a proper way to remove
          * an element from an array by its key. Unsetting the key results in the element
          * being left in the array as null so we have to pull null values.
          *
          * "Using "$unset" with an expression like this "array.$" will result in the array item becoming null, not being removed. You can issue an update with "{$pull:{x:null}}" to remove all nulls."
          * http://www.mongodb.org/display/DOCS/Updating#Updating-%24unset
          */
         $mapping = $coll->getMapping();
         if ($mapping['strategy'] !== 'set') {
             $this->executeQuery($parent, array($this->cmd . 'pull' => array($propertyPath => null)), $options);
         }
     }
 }