Backup #460
| ID | 460 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/PromptsController.php |
| Version | 4 |
| Typ |
modified |
| Größe | 4.1 KB |
| Hash | ec01ba1ddcbae5b9d72172e32aec2c3f78693b14f47b6d7e53c10610212b5715 |
| Datum | 2025-12-22 10:30:17 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace Controller;
use Framework\Controller;
use UseCases\Prompts\ManagePromptsUseCase;
class PromptsController extends Controller
{
private ManagePromptsUseCase $promptsUseCase;
private const PROMPT_TYPES = [
'critic' => 'Critic-Prompt',
'generate' => 'Generierungs-Prompt',
'revise' => 'Revisions-Prompt',
'system' => 'System-Prompt',
'other' => 'Sonstiges',
];
public function __construct(?ManagePromptsUseCase $promptsUseCase = null)
{
$this->promptsUseCase = $promptsUseCase ?? new ManagePromptsUseCase();
}
public function index(): void
{
$this->view('prompts.index', [
'title' => 'Prompts verwalten',
'prompts' => array_map(fn ($dto) => (array) $dto, $this->promptsUseCase->getAll()),
'stats' => $this->promptsUseCase->getStatistics(),
'promptTypes' => self::PROMPT_TYPES,
]);
}
public function promptsNew(): void
{
$this->view('prompts.form', [
'title' => 'Neuer Prompt',
'prompt' => null,
'promptTypes' => self::PROMPT_TYPES,
'isEdit' => false,
]);
}
public function store(): void
{
$this->requireCsrf();
$result = $this->promptsUseCase->create(
name: $_POST['name'] ?? '',
version: $_POST['version'] ?? '1.0',
content: $_POST['content'] ?? '',
isActive: isset($_POST['is_active'])
);
if (!$result->success) {
$_SESSION['error'] = $result->message;
header('Location: /prompts/new');
exit;
}
$_SESSION['success'] = $result->message;
header('Location: /prompts/' . $result->id);
exit;
}
public function show(string $id): void
{
$prompt = $this->promptsUseCase->getById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$this->view('prompts.show', [
'title' => $prompt->name,
'prompt' => (array) $prompt,
'linkedCritics' => $this->promptsUseCase->getLinkedCritics((int) $id),
'promptTypes' => self::PROMPT_TYPES,
]);
}
public function edit(string $id): void
{
$prompt = $this->promptsUseCase->getById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$this->view('prompts.form', [
'title' => 'Bearbeiten: ' . $prompt->name,
'prompt' => (array) $prompt,
'promptTypes' => self::PROMPT_TYPES,
'isEdit' => true,
]);
}
public function update(string $id): void
{
$this->requireCsrf();
$result = $this->promptsUseCase->update(
id: (int) $id,
name: $_POST['name'] ?? '',
version: $_POST['version'] ?? '1.0',
content: $_POST['content'] ?? '',
isActive: isset($_POST['is_active'])
);
if (!$result->success) {
$_SESSION['error'] = $result->message;
header('Location: /prompts/' . $id . '/edit');
exit;
}
$_SESSION['success'] = $result->message;
header('Location: /prompts/' . $id);
exit;
}
public function delete(string $id): void
{
$this->requireCsrf();
$result = $this->promptsUseCase->delete((int) $id);
if (!$result->success) {
$_SESSION['error'] = $result->message;
header('Location: /prompts/' . $id);
exit;
}
$_SESSION['success'] = $result->message;
header('Location: /prompts');
exit;
}
public function duplicate(string $id): void
{
$this->requireCsrf();
$result = $this->promptsUseCase->duplicate((int) $id);
if (!$result->success) {
$_SESSION['error'] = $result->message;
header('Location: /prompts/' . $id);
exit;
}
$_SESSION['success'] = $result->message;
header('Location: /prompts/' . $result->id . '/edit');
exit;
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1752 |
17 |
modified |
5.3 KB |
2025-12-27 12:46 |
| 1749 |
16 |
modified |
4.9 KB |
2025-12-27 12:45 |
| 1670 |
15 |
modified |
4.6 KB |
2025-12-27 11:29 |
| 865 |
14 |
modified |
4.6 KB |
2025-12-23 08:50 |
| 689 |
13 |
modified |
4.5 KB |
2025-12-23 07:52 |
| 507 |
12 |
modified |
4.6 KB |
2025-12-22 15:42 |
| 506 |
11 |
modified |
4.6 KB |
2025-12-22 15:42 |
| 505 |
10 |
modified |
4.7 KB |
2025-12-22 15:42 |
| 486 |
9 |
modified |
4.4 KB |
2025-12-22 15:26 |
| 485 |
8 |
modified |
4.2 KB |
2025-12-22 15:26 |
| 484 |
7 |
modified |
4.1 KB |
2025-12-22 15:26 |
| 462 |
6 |
modified |
4.1 KB |
2025-12-22 10:30 |
| 461 |
5 |
modified |
4.1 KB |
2025-12-22 10:30 |
| 460 |
4 |
modified |
4.1 KB |
2025-12-22 10:30 |
| 451 |
3 |
modified |
4.7 KB |
2025-12-22 10:25 |
| 450 |
2 |
modified |
4.6 KB |
2025-12-22 10:24 |
| 444 |
1 |
modified |
7.0 KB |
2025-12-22 10:16 |
← Zurück zur Übersicht