private function deleteElements(object $parent, array $collections, array $options) : void
    {
        $pathCollMap   = [];
        $paths         = [];
        $deleteDiffMap = [];

        foreach ($collections as $coll) {
            $coll->initialize();
            if (! $this->uow->isCollectionScheduledForUpdate($coll)) {
                continue;
            }
            $deleteDiff = $coll->getDeleteDiff();

            if (empty($deleteDiff)) {
                continue;
            }
            [$propertyPath ] = $this->getPathAndParent($coll);

            $pathCollMap[$propertyPath]   = $coll;
            $paths[]                      = $propertyPath;
            $deleteDiffMap[$propertyPath] = $deleteDiff;
        }

        $paths        = $this->excludeSubPaths($paths);
        $deleteColls  = array_intersect_key($pathCollMap, array_flip($paths));
        $unsetPayload = [];
        $pullPayload  = [];
        foreach ($deleteColls as $propertyPath => $coll) {
            $deleteDiff = $deleteDiffMap[$propertyPath];
            foreach ($deleteDiff as $key => $document) {
                $unsetPayload[$propertyPath . '.' . $key] = true;
            }
            $pullPayload[$propertyPath] = null;
        }

        if (! empty($unsetPayload)) {
            $this->executeQuery($parent, ['$unset' => $unsetPayload], $options);
        }
        if (empty($pullPayload)) {
            return;
        }

        /**
         * @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, ['$pull' => $pullPayload], $options);
    }
private function deleteElements(object $parent, array $collections, array $options) : void
    {
        $pathCollMap   = [];
        $paths         = [];
        $deleteDiffMap = [];

        foreach ($collections as $coll) {
            $coll->initialize();
            if (! $this->uow->isCollectionScheduledForUpdate($coll)) {
                continue;
            }
            $deleteDiff = $coll->getDeleteDiff();

            if (empty($deleteDiff)) {
                continue;
            }
            [$propertyPath ] = $this->getPathAndParent($coll);

            $pathCollMap[$propertyPath]   = $coll;
            $paths[]                      = $propertyPath;
            $deleteDiffMap[$propertyPath] = $deleteDiff;
        }

        $paths        = $this->excludeSubPaths($paths);
        $deleteColls  = array_intersect_key($pathCollMap, array_flip($paths));
        $unsetPayload = [];
        $pullPayload  = [];
        foreach ($deleteColls as $propertyPath => $coll) {
            $deleteDiff = $deleteDiffMap[$propertyPath];
            foreach ($deleteDiff as $key => $document) {
                $unsetPayload[$propertyPath . '.' . $key] = true;
            }
            $pullPayload[$propertyPath] = null;
        }

        if (! empty($unsetPayload)) {
            $this->executeQuery($parent, ['$unset' => $unsetPayload], $options);
        }
        if (empty($pullPayload)) {
            return;
        }

        /**
         * @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, ['$pull' => $pullPayload], $options);
    }
private function deleteElements ( object $ parent , array $ collections , array $ options ) : void { $ pathCollMap = [ ] ; $ paths = [ ] ; $ deleteDiffMap = [ ] ; foreach ( $ collections as $ coll ) { $ coll -> initialize ( ) ; if ( ! $ this -> uow -> isCollectionScheduledForUpdate ( $ coll ) ) { continue ; } $ deleteDiff = $ coll -> getDeleteDiff ( ) ; if ( empty ( $ deleteDiff ) ) { continue ; } [ $ propertyPath ] = $ this -> getPathAndParent ( $ coll ) ; $ pathCollMap [ $ propertyPath ] = $ coll ; $ paths [ ] = $ propertyPath ; $ deleteDiffMap [ $ propertyPath ] = $ deleteDiff ; } $ paths = $ this -> excludeSubPaths ( $ paths ) ; $ deleteColls = array_intersect_key ( $ pathCollMap , array_flip ( $ paths ) ) ; $ unsetPayload = [ ] ; $ pullPayload = [ ] ; foreach ( $ deleteColls as $ propertyPath => $ coll ) { $ deleteDiff = $ deleteDiffMap [ $ propertyPath ] ; foreach ( $ deleteDiff as $ key => $ document ) { $ unsetPayload [ $ propertyPath . '.' . $ key ] = true ; } $ pullPayload [ $ propertyPath ] = null ; } if ( ! empty ( $ unsetPayload ) ) { $ this -> executeQuery ( $ parent , [ '$unset' => $ unsetPayload ] , $ options ) ; } if ( empty ( $ pullPayload ) ) { return ; } /**
         * @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 , [ '$pull' => $ pullPayload ] , $ options ) ; }
Deletes removed elements from a list of PersistentCollection instances.

This method is intended to be used with the "pushAll" and "addToSet" strategies.

@param PersistentCollectionInterface[] $collections
@param array                           $options
Deletes removed elements from a list of PersistentCollection instances .