/** * Execute the findAndModify command with the remove option and delete any * chunks for the document. * * @see Collection::doFindAndRemove() * @param array $query * @param array $options * @return array|null */ protected function doFindAndRemove(array $query, array $options = []) { $document = parent::doFindAndRemove($query, $options); if (isset($document)) { // Remove the file data from the chunks collection $this->mongoCollection->chunks->remove(['files_id' => $document['_id']], $options); } return $document; }