Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Export/import screen template media
  • Loading branch information
mcraeteisha committed Sep 21, 2026
commit 8c31fdd6219e1aae16be02a118a0d26592a9cfbb
22 changes: 22 additions & 0 deletions ProcessMaker/ImportExport/Exporters/ScreenTemplatesExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,44 @@
namespace ProcessMaker\ImportExport\Exporters;

use Illuminate\Support\Facades\Auth;
use ProcessMaker\ImportExport\DependentType;

class ScreenTemplatesExporter extends ExporterBase
{
public $handleDuplicatesByIncrementing = ['name'];

public function export() : void
{
$media = $this->model->getMedia($this->model->media_collection);

$this->addReference(DependentType::MEDIA, $media->map(function ($item) {
return [
'file_name' => $item->file_name,
'custom_properties' => $item->custom_properties,
'base64' => base64_encode(file_get_contents($item->getPath())),
];
})->all());
}

public function import() : bool
{
$screenTemplate = $this->model;
$screenTemplate->user_id = Auth::user()->id;
$screenTemplate->is_default_template = 0;
$screenTemplate->media_collection = 'st-' . $screenTemplate->uuid . '-media';
$screenTemplate->save();

foreach ($this->getReference(DependentType::MEDIA) ?? [] as $item) {
if (empty($item['base64'])) {
continue;
}

$screenTemplate->addMediaFromBase64($item['base64'])
->usingFileName($item['file_name'])
->withCustomProperties($item['custom_properties'] ?? [])
->toMediaCollection($screenTemplate->media_collection);
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

return true;
}
}