Skip to content

Commit 7173eba

Browse files
Enhance MediaExporter to update FlowGenie media configuration upon media import when package-ai is available
1 parent 7ea2dc3 commit 7173eba

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ProcessMaker/ImportExport/Exporters/MediaExporter.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,22 @@ public function import(): bool
4444

4545
$ref = $this->getReference(DependentType::MEDIA);
4646
if ($ref && isset($ref['base64'])) {
47-
$this->model->model->addMediaFromBase64($ref['base64'])
47+
$newMedia = $this->model->model->addMediaFromBase64($ref['base64'])
4848
->usingFileName($this->model->file_name)
4949
->withCustomProperties($this->model->custom_properties)
5050
->toMediaCollection($this->model->collection_name);
51+
52+
if (hasPackage('package-ai')) {
53+
$updaterClass = 'ProcessMaker\\Package\\PackageAi\\Services\\FlowGenieMediaConfigUpdater';
54+
if (class_exists($updaterClass)) {
55+
$updaterClass::updateForMediaImport(
56+
(string) $this->model->model_type,
57+
(int) $this->model->model_id,
58+
(int) $this->model->id,
59+
(int) $newMedia->id
60+
);
61+
}
62+
}
5163
}
5264

5365
// We should delete the model, because the Spatie library recreates it.

0 commit comments

Comments
 (0)