/** @override */ protected function doInsert(array &$a, array $options = array()) { // If file exists and is dirty then lets persist the file and store the file path or the bytes if (isset($a['file'])) { $file = $a['file']; // instanceof GridFSFile unset($a['file']); if ($file->isDirty()) { $this->storeFile($file, $a, $options); } else { parent::doInsert($a, $options); } } else { parent::doInsert($a, $options); } $a['file'] = $file; return $a; }
/** @override */ protected function doInsert(array &$a, array $options = array()) { // If there is no file, perform a basic insertion if (!isset($a['file'])) { parent::doInsert($a, $options); return; } /* If the file is dirty (i.e. it must be persisted), delegate to the * storeFile() method. Otherwise, perform a basic insertion. */ $file = $a['file']; // instanceof GridFSFile unset($a['file']); if ($file->isDirty()) { $this->storeFile($file, $a, $options); } else { parent::doInsert($a, $options); } $a['file'] = $file; return $a; }