This commit is contained in:
Yuri Kuznetsov
2022-03-12 20:12:38 +02:00
parent f5d5c4e75e
commit a5139255f2
2 changed files with 24 additions and 7 deletions

View File

@@ -68,7 +68,7 @@ class PrinterController
$params = $params ?? new Params();
$data = $data ?? new Data();
return $this->createPrinter('entity')->print($this->template, $entity, $params, $data);
return $this->createEntityPrinter()->print($this->template, $entity, $params, $data);
}
/**
@@ -79,17 +79,30 @@ class PrinterController
$params = $params ?? new Params();
$IdDataMap = $IdDataMap ?? new IdDataMap();
return $this->createPrinter('collection')->print($this->template, $collection, $params, $IdDataMap);
return $this->createCollectionPrinter()->print($this->template, $collection, $params, $IdDataMap);
}
private function createPrinter(string $type): object
private function createEntityPrinter(): EntityPrinter
{
/** @var ?class-string */
$className = $this->metadata
->get(['app', 'pdfEngines', $this->engine, 'implementationClassNameMap', $type]) ?? null;
->get(['app', 'pdfEngines', $this->engine, 'implementationClassNameMap', 'entity']) ?? null;
if (!$className) {
throw new Error("Unknown PDF engine '{$this->engine}', type '{$type}'.");
throw new Error("Unknown PDF engine '{$this->engine}', type 'entity'.");
}
return $this->injectableFactory->create($className);
}
private function createCollectionPrinter(): CollectionPrinter
{
/** @var ?class-string */
$className = $this->metadata
->get(['app', 'pdfEngines', $this->engine, 'implementationClassNameMap', 'collection']) ?? null;
if (!$className) {
throw new Error("Unknown PDF engine '{$this->engine}', type 'collection'.");
}
return $this->injectableFactory->create($className);

View File

@@ -550,14 +550,18 @@ class HookProcessor
if (is_null($this->statusFields)) {
$this->statusFields = [];
/** @var array<string,array<string,mixed>> */
$scopes = $this->metadata->get('scopes', []);
foreach ($scopes as $scope => $data) {
if (empty($data['statusField'])) {
/** @var ?string */
$statusField = $data['statusField'] ?? null;
if (!$statusField) {
continue;
}
$this->statusFields[$scope] = $data['statusField'];
$this->statusFields[$scope] = $statusField;
}
}