Replace all SongGroup/SongArrangementGroup model usages with Label/SongArrangementLabel after the schema migration to global labels. Updates 12 app files and 11 test files: - SongService: createDefaultGroups now finds-or-creates global Labels by name - ArrangementController: validates label_id (labels are global, no song-ownership) - ProImportService: imports groups as Labels (firstOrCreate by name); does not overwrite existing label colors per spec - ProExportService/SongPdfController/TranslationService/etc: traverse via arrangements -> arrangementLabels -> label -> songSlides chain - All test factories and assertions adapted to label-based schema
67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
|
|
require_once dirname(__DIR__, 2).'/vendor/autoload.php';
|
|
|
|
use Rv\Data\Color;
|
|
use Rv\Data\MacrosDocument;
|
|
use Rv\Data\MacrosDocument\Macro;
|
|
use Rv\Data\MacrosDocument\MacroCollection;
|
|
use Rv\Data\MacrosDocument\MacroCollection\Item;
|
|
use Rv\Data\UUID;
|
|
|
|
function makeUuid(string $value): UUID
|
|
{
|
|
$uuid = new UUID;
|
|
$uuid->setString(strtoupper($value));
|
|
|
|
return $uuid;
|
|
}
|
|
|
|
function makeColor(float $r, float $g, float $b, float $a = 1.0): Color
|
|
{
|
|
$color = new Color;
|
|
$color->setRed($r);
|
|
$color->setGreen($g);
|
|
$color->setBlue($b);
|
|
$color->setAlpha($a);
|
|
|
|
return $color;
|
|
}
|
|
|
|
$doc = new MacrosDocument;
|
|
|
|
$macros = [
|
|
['uuid' => 'AAAAAAAA-1111-2222-3333-FFFFFFFFFFFF', 'name' => 'Copyright Makro', 'r' => 1.0, 'g' => 0.5, 'b' => 0.0],
|
|
['uuid' => 'BBBBBBBB-1111-2222-3333-FFFFFFFFFFFF', 'name' => 'Vers Makro', 'r' => 0.0, 'g' => 0.8, 'b' => 0.2],
|
|
['uuid' => 'CCCCCCCC-1111-2222-3333-FFFFFFFFFFFF', 'name' => 'Refrain Makro', 'r' => 0.2, 'g' => 0.4, 'b' => 1.0],
|
|
];
|
|
|
|
$macroObjects = [];
|
|
foreach ($macros as $data) {
|
|
$macro = new Macro;
|
|
$macro->setUuid(makeUuid($data['uuid']));
|
|
$macro->setName($data['name']);
|
|
$macro->setColor(makeColor($data['r'], $data['g'], $data['b']));
|
|
$macro->setTriggerOnStartup(false);
|
|
$macro->setImageType(0);
|
|
$macroObjects[] = $macro;
|
|
}
|
|
$doc->setMacros($macroObjects);
|
|
|
|
$collection = new MacroCollection;
|
|
$collection->setUuid(makeUuid('8D02FC57-83F8-4042-9B90-81C229728426'));
|
|
$collection->setName('--MAIN--');
|
|
|
|
$items = [];
|
|
foreach ($macros as $data) {
|
|
$item = new Item;
|
|
$item->setMacroId(makeUuid($data['uuid']));
|
|
$items[] = $item;
|
|
}
|
|
$collection->setItems($items);
|
|
$doc->setMacroCollections([$collection]);
|
|
|
|
$output = $doc->serializeToString();
|
|
file_put_contents(__DIR__.'/macros-sample.bin', $output);
|
|
echo 'Written '.strlen($output).' bytes'.PHP_EOL;
|