/** * @param core_kernel_classes_Resource $instance * @param $tmpFile * * @return \common_report_Report */ public function updateInstanceAttachment($instance, $tmpFile) { $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS); StorageService::removeAttachedFile($instance); $fileResource = StorageService::storeFile($tmpFile); $property = new \core_kernel_classes_Property(self::PROPERTY_FILE_CONTENT); $instance->editPropertyValues($property, $fileResource); $report->setMessage(__('%s updated', $instance->getLabel())); $report->setData($instance); return $report; }
/** * Overloaded delete, also takes care about attached files * @throws \Exception * @throws \tao_models_classes_MissingRequestParameterException */ public function delete() { if ($this->hasRequestParameter('uri')) { $instance = $this->getCurrentInstance(); StorageService::removeAttachedFile($instance); } parent::delete(); }