Backup #1096
| ID | 1096 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/RelationController.php |
| Version | 14 |
| Typ |
modified |
| Größe | 4.3 KB |
| Hash | c929206db44d4ad46cd271cf61b31ef9cd8bcc70feaca4f920fab633ca7dbdb2 |
| Datum | 2025-12-25 09:19:29 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Controller;
// @responsibility: HTTP-Endpunkte für Semantic Explorer Relationen (CRUD)
use Domain\Repository\EntityRepositoryInterface;
use Domain\Repository\RelationRepositoryInterface;
use Framework\Controller;
use Infrastructure\Formatter\ApiResponseFormatter;
class RelationController extends Controller
{
private RelationRepositoryInterface $relationRepository;
private EntityRepositoryInterface $entityRepository;
private ApiResponseFormatter $apiFormatter;
public function __construct(
RelationRepositoryInterface $relationRepository,
EntityRepositoryInterface $entityRepository,
ApiResponseFormatter $apiFormatter
) {
$this->relationRepository = $relationRepository;
$this->entityRepository = $entityRepository;
$this->apiFormatter = $apiFormatter;
}
/**
* GET /semantic-explorer/relationen
* Beziehungen zwischen Entitaeten
*/
public function index(): void
{
$type = $this->getString('type');
$relations = $this->relationRepository->findFiltered($type);
$relationTypes = $this->relationRepository->getTypes();
$stats = $this->relationRepository->getStats();
$this->view('semantic-explorer.relationen', [
'title' => 'Relationen',
'relations' => $relations,
'relationTypes' => $relationTypes,
'stats' => $stats,
'currentType' => $type,
]);
}
/**
* GET /semantic-explorer/relationen/new
*/
public function create(): void
{
$this->view('semantic-explorer.relationen.new', [
'title' => 'Neue Relation',
'entities' => $this->entityRepository->getAllEntitiesSimple(),
'relationTypes' => $this->relationRepository->getTypesList(),
]);
}
/**
* POST /semantic-explorer/relationen
*/
public function store(): void
{
$input = $this->getJsonInput();
$sourceId = (int) ($input['source_entity_id'] ?? 0);
$targetId = (int) ($input['target_entity_id'] ?? 0);
$type = trim($input['relation_type'] ?? '');
$strength = (float) ($input['strength'] ?? 1.0);
if ($sourceId === 0 || $targetId === 0 || $type === '') {
$this->json($this->apiFormatter->validationError('Alle Felder sind erforderlich'), 400);
return;
}
try {
$id = $this->relationRepository->create($sourceId, $targetId, $type, $strength);
$this->json($this->apiFormatter->created($id, 'Relation erstellt'));
} catch (\Exception $e) {
$this->json($this->apiFormatter->error($e->getMessage(), 'SERVER_ERROR'), 500);
}
}
/**
* GET /semantic-explorer/relationen/{id}/edit
*/
public function edit(int $id): void
{
$relation = $this->relationRepository->find($id);
if ($relation === null) {
$this->notFound('Relation nicht gefunden');
}
$this->view('semantic-explorer.relationen.edit', [
'title' => 'Relation bearbeiten',
'relation' => $relation,
'relationTypes' => $this->relationRepository->getTypesList(),
]);
}
/**
* POST /semantic-explorer/relationen/{id}
*/
public function update(int $id): void
{
$input = $this->getJsonInput();
$type = trim($input['relation_type'] ?? '');
$strength = (float) ($input['strength'] ?? 1.0);
if ($type === '') {
$this->json($this->apiFormatter->validationError('Beziehungstyp ist erforderlich', ['relation_type' => 'Pflichtfeld']), 400);
return;
}
try {
$this->relationRepository->update($id, $type, $strength);
$this->json($this->apiFormatter->ok('Relation aktualisiert'));
} catch (\Exception $e) {
$this->json($this->apiFormatter->error($e->getMessage(), 'SERVER_ERROR'), 500);
}
}
/**
* POST /semantic-explorer/relationen/{id}/delete
*/
public function destroy(int $id): void
{
try {
$this->relationRepository->delete($id);
$this->json($this->apiFormatter->ok('Relation gelöscht'));
} catch (\Exception $e) {
$this->json($this->apiFormatter->error($e->getMessage(), 'SERVER_ERROR'), 500);
}
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1718 |
16 |
modified |
4.9 KB |
2025-12-27 12:30 |
| 1717 |
15 |
modified |
4.3 KB |
2025-12-27 12:29 |
| 1096 |
14 |
modified |
4.3 KB |
2025-12-25 09:19 |
| 1095 |
13 |
modified |
4.3 KB |
2025-12-25 09:19 |
| 1080 |
12 |
modified |
4.3 KB |
2025-12-25 02:29 |
| 1079 |
11 |
modified |
4.3 KB |
2025-12-25 02:29 |
| 1078 |
10 |
modified |
4.3 KB |
2025-12-25 02:28 |
| 1077 |
9 |
modified |
4.3 KB |
2025-12-25 02:28 |
| 1076 |
8 |
modified |
4.1 KB |
2025-12-25 02:28 |
| 693 |
7 |
modified |
4.1 KB |
2025-12-23 07:52 |
| 615 |
6 |
modified |
4.2 KB |
2025-12-23 04:42 |
| 521 |
5 |
modified |
4.1 KB |
2025-12-22 15:50 |
| 520 |
4 |
modified |
4.1 KB |
2025-12-22 15:50 |
| 519 |
3 |
modified |
3.8 KB |
2025-12-22 15:49 |
| 305 |
2 |
modified |
3.8 KB |
2025-12-22 08:05 |
| 304 |
1 |
modified |
3.8 KB |
2025-12-22 08:05 |
← Zurück zur Übersicht