Tabellen und Bilder gehören zur festen Auswahl von FormattedText. Ein Bild ist ein Verweis auf eine freigegebene Bildfassung und kommt per Picker aus dem Medienbestand; der Stand schreibt die Bildfassung mit fest, die Rechte entscheidet DecideAccess. Der PDF-Satz (PdfFlow) ist für Übung und kommende Dokumente gemeinsam; PdfDocument kann zusätzlich Bilder, Flächen, Verweise und Lesezeichen, Belege bleiben byte-gleich. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use App\Domain\Entitlement\Grant;
|
|
use Closure;
|
|
|
|
/**
|
|
* Die Bilder eines PDF: löst jedes Bild einmal auf und merkt sich, welche Bildfassungen tatsächlich gedruckt wurden,
|
|
* damit der Ausgabenachweis sie wie jede andere Fassung des PDF führt.
|
|
*/
|
|
final class PdfImages
|
|
{
|
|
/** @var array<int, array{jpeg?: string, width?: int, height?: int, note?: string, grant: ?Grant, version: ?ContentElementVersion}|null> */
|
|
private array $resolved = [];
|
|
|
|
/**
|
|
* @param Closure(int): ?array{jpeg?: string, width?: int, height?: int, note?: string, grant: ?Grant, version: ?ContentElementVersion} $resolve
|
|
*/
|
|
public function __construct(private readonly Closure $resolve) {}
|
|
|
|
/**
|
|
* @return array{jpeg?: string, width?: int, height?: int, note?: string}|null
|
|
*/
|
|
public function __invoke(int $id): ?array
|
|
{
|
|
if (! array_key_exists($id, $this->resolved)) {
|
|
$this->resolved[$id] = ($this->resolve)($id);
|
|
}
|
|
|
|
return $this->resolved[$id];
|
|
}
|
|
|
|
/**
|
|
* @return list<array{version: ContentElementVersion, grant: Grant}>
|
|
*/
|
|
public function used(): array
|
|
{
|
|
$used = [];
|
|
|
|
foreach ($this->resolved as $found) {
|
|
if ($found !== null && isset($found['jpeg']) && $found['version'] instanceof ContentElementVersion && $found['grant'] instanceof Grant) {
|
|
$used[] = ['version' => $found['version'], 'grant' => $found['grant']];
|
|
}
|
|
}
|
|
|
|
return $used;
|
|
}
|
|
}
|