pp-planer/app/Services/ServiceImageResolver.php
Thorsten Bus ae42b48753 feat(songs): per-song sections + section editing; fix CCLI import bugs
Refactor lyric storage so each song owns its sections instead of sharing
global labels. Adds song_sections (per song+label) owning song_slides;
labels stay global ProPresenter group tags (name/color/macro). Arrangements
now reference sections, so editing/importing one song no longer corrupts
others that share a label name.

- New: song_sections table + migration with safe backfill; SongSection,
  SongArrangementSection models; SongSectionController (edit/add/delete
  sections, immediate persistence) wired into SongEditModal.
- Refactor writers/readers: CcliImport, ProImport, SongService,
  ArrangementController, SongController, ProExport, PDF, Translation
  (translation reset now section-scoped), CCLI pairing.
- CCLI import fixes: parse SongSelect copy-icon format (German "Vers"
  abbrev + trailing author), fill empty CTS-synced songs instead of
  blocking as duplicate, distinct label colors per section kind,
  import&edit/existing-song open the edit modal (no 404/405), teleport
  paste dialog above assign dialog, preview shows section content,
  correct SongSelect search URL, copy-icon instructions.
- Bookmarklet clicks #generalCopyLyricsButton and captures clipboard;
  serves correct host from request.
- Export: embed key-visual/background under fixed bundle-relative names.
- Tests updated for the section model; new section + isolation coverage.
2026-05-31 14:45:47 +02:00

48 lines
1.4 KiB
PHP

<?php
namespace App\Services;
use App\Models\Service;
use App\Models\Setting;
use Illuminate\Support\Facades\Storage;
class ServiceImageResolver
{
/**
* Fixed export filename for the key-visual image. The image bytes are
* embedded under this name AND referenced by this name inside the .pro file.
*/
public const KEY_VISUAL_EXPORT_NAME = 'KEY_VISUAL.jpg';
/**
* Fixed export filename for the background image. The image bytes are
* embedded under this name AND referenced by this name inside the .pro file.
*/
public const BACKGROUND_EXPORT_NAME = 'BACKGROUND.jpg';
public function keyVisualFor(Service $service): ?string
{
return $this->resolve($service->key_visual_filename, 'current_key_visual');
}
public function backgroundFor(Service $service): ?string
{
return $this->resolve($service->background_filename, 'current_background');
}
private function resolve(?string $serviceFilename, string $settingKey): ?string
{
if ($serviceFilename !== null && Storage::disk('public')->exists($serviceFilename)) {
return $serviceFilename;
}
$globalFilename = Setting::get($settingKey);
if ($globalFilename !== null && Storage::disk('public')->exists($globalFilename)) {
return $globalFilename;
}
return null;
}
}