Backup #717
| ID | 717 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/UseCases/Protokoll/ViewProtokollUseCase.php |
| Version | 1 |
| Typ |
modified |
| Größe | 2.3 KB |
| Hash | d59e13232eeb9c15358f994329a60f93c322d9aa48d0d2f37e743830a140d33b |
| Datum | 2025-12-23 07:55:54 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace UseCases\Protokoll;
use Domain\ValueObject\Pagination;
use Infrastructure\Persistence\KiProtokollRepository;
final class ViewProtokollUseCase
{
private KiProtokollRepository $protokollRepo;
public function __construct(?KiProtokollRepository $protokollRepo = null)
{
$this->protokollRepo = $protokollRepo ?? new KiProtokollRepository();
}
public function getPaginated(
?string $search,
?string $status,
?string $model,
Pagination $pagination
): array {
$totalCount = $this->protokollRepo->countFiltered($search, $status, $model);
$updatedPagination = $pagination->withTotal($totalCount);
$entries = $this->protokollRepo->findPaginated(
$search,
$status,
$model,
$updatedPagination->limit,
$updatedPagination->offset
);
return [
'entries' => array_map(fn (array $row) => ProtokollDTO::fromArray($row), $entries),
'pagination' => $updatedPagination,
];
}
public function getById(int $id): ?ProtokollDTO
{
$entry = $this->protokollRepo->findById($id);
if ($entry === null) {
return null;
}
$entry['request_formatted'] = $this->formatJson($entry['request']);
$entry['response_formatted'] = $this->formatJson($entry['response']);
return ProtokollDTO::fromArray($entry);
}
public function getNavigation(int $id): array
{
return [
'prevId' => $this->protokollRepo->findPreviousId($id),
'nextId' => $this->protokollRepo->findNextId($id),
];
}
public function getStatistics(): array
{
return $this->protokollRepo->getStatistics();
}
public function getDistinctModels(): array
{
return $this->protokollRepo->getDistinctModels();
}
private function formatJson(?string $json): string
{
if ($json === null || $json === '') {
return '-';
}
$decoded = json_decode($json, true);
if ($decoded === null) {
return htmlspecialchars($json);
}
$formatted = json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
return $formatted !== false ? $formatted : htmlspecialchars($json);
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 838 |
2 |
modified |
2.4 KB |
2025-12-23 08:17 |
| 717 |
1 |
modified |
2.3 KB |
2025-12-23 07:55 |
← Zurück zur Übersicht