fix(export): inject macros for information/moderation/sermon/agenda_item parts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
84adf2b6fb
commit
eee35722fb
|
|
@ -15,6 +15,10 @@ class ProBundleExportService
|
||||||
{
|
{
|
||||||
private const ALLOWED_BLOCK_TYPES = ['information', 'moderation', 'sermon'];
|
private const ALLOWED_BLOCK_TYPES = ['information', 'moderation', 'sermon'];
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private readonly MacroResolutionService $macroResolutionService,
|
||||||
|
) {}
|
||||||
|
|
||||||
public function generateBundle(Service $service, string $blockType): string
|
public function generateBundle(Service $service, string $blockType): string
|
||||||
{
|
{
|
||||||
if (! in_array($blockType, self::ALLOWED_BLOCK_TYPES, true)) {
|
if (! in_array($blockType, self::ALLOWED_BLOCK_TYPES, true)) {
|
||||||
|
|
@ -28,7 +32,7 @@ public function generateBundle(Service $service, string $blockType): string
|
||||||
|
|
||||||
$groupName = ucfirst($blockType);
|
$groupName = ucfirst($blockType);
|
||||||
|
|
||||||
return $this->buildBundleFromSlides($slides, $groupName);
|
return $this->buildBundleFromSlides($slides, $groupName, $service, $blockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateAgendaItemBundle(ServiceAgendaItem $agendaItem): string
|
public function generateAgendaItemBundle(ServiceAgendaItem $agendaItem): string
|
||||||
|
|
@ -68,11 +72,11 @@ public function generateAgendaItemBundle(ServiceAgendaItem $agendaItem): string
|
||||||
->orderBy('sort_order')
|
->orderBy('sort_order')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $this->buildBundleFromSlides($slides, $title);
|
return $this->buildBundleFromSlides($slides, $title, $agendaItem->service, 'agenda_item');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param \Illuminate\Database\Eloquent\Collection<int, \App\Models\Slide> $slides */
|
/** @param \Illuminate\Database\Eloquent\Collection<int, \App\Models\Slide> $slides */
|
||||||
private function buildBundleFromSlides($slides, string $groupName): string
|
private function buildBundleFromSlides($slides, string $groupName, ?Service $service = null, ?string $partType = null): string
|
||||||
{
|
{
|
||||||
$slideData = [];
|
$slideData = [];
|
||||||
$mediaFiles = [];
|
$mediaFiles = [];
|
||||||
|
|
@ -91,11 +95,28 @@ private function buildBundleFromSlides($slides, string $groupName): string
|
||||||
|
|
||||||
$mediaFiles[$imageFilename] = $imageContent;
|
$mediaFiles[$imageFilename] = $imageContent;
|
||||||
|
|
||||||
$slideData[] = [
|
$singleSlideData = [
|
||||||
'media' => $imageFilename,
|
'media' => $imageFilename,
|
||||||
'format' => 'JPG',
|
'format' => 'JPG',
|
||||||
'label' => $slide->original_filename,
|
'label' => $slide->original_filename,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($service !== null && $partType !== null) {
|
||||||
|
$slideIndex = count($slideData);
|
||||||
|
$totalSlides = $slides->count();
|
||||||
|
$macros = $this->macroResolutionService->macrosForSlide(
|
||||||
|
$service,
|
||||||
|
$partType,
|
||||||
|
['index' => $slideIndex, 'total' => $totalSlides, 'label_id' => null],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (! empty($macros)) {
|
||||||
|
// ProPresenter parser currently supports one `macro` entry per slide
|
||||||
|
$singleSlideData['macro'] = $macros[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$slideData[] = $singleSlideData;
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = [
|
$groups = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue