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
41 lines
1 KiB
PHP
41 lines
1 KiB
PHP
<?php
|
|
|
|
require_once dirname(__DIR__, 2).'/vendor/autoload.php';
|
|
|
|
use Rv\Data\Action\Label;
|
|
use Rv\Data\Color;
|
|
use Rv\Data\ProLabelsDocument;
|
|
|
|
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 ProLabelsDocument;
|
|
|
|
$labels = [
|
|
['name' => 'Copyright', 'r' => 0.8, 'g' => 0.2, 'b' => 0.2],
|
|
['name' => 'Vers 1', 'r' => 0.2, 'g' => 0.6, 'b' => 0.9],
|
|
['name' => 'Refrain', 'r' => 0.9, 'g' => 0.7, 'b' => 0.1],
|
|
['name' => 'Brücke', 'r' => 0.5, 'g' => 0.1, 'b' => 0.8],
|
|
];
|
|
|
|
$labelObjects = [];
|
|
foreach ($labels as $data) {
|
|
$label = new Label;
|
|
$label->setText($data['name']);
|
|
$label->setColor(makeColor($data['r'], $data['g'], $data['b']));
|
|
$labelObjects[] = $label;
|
|
}
|
|
$doc->setLabels($labelObjects);
|
|
|
|
$output = $doc->serializeToString();
|
|
file_put_contents(__DIR__.'/labels-sample.bin', $output);
|
|
echo 'Written '.strlen($output).' bytes'.PHP_EOL;
|