Backup #301
| ID | 301 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/EntityController.php |
| Version | 1 |
| Typ |
modified |
| Größe | 4.8 KB |
| Hash | ca0a37d3dba263d98f69b019fc078eb5ac4e084013c2529a028bb80e811b626f |
| Datum | 2025-12-22 08:04:58 |
| 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 Infrastructure\SemanticExplorerRepository;
/**
* EntityController - CRUD for Semantic Explorer Entities
*
* Extracted from SemanticExplorerController for SRP compliance.
*/
class EntityController extends Controller
{
private SemanticExplorerRepository $repository;
public function __construct()
{
$this->repository = new SemanticExplorerRepository();
}
/**
* GET /semantic-explorer/entitaeten
* Liste aller Entitaeten
*/
public function index(): void
{
$type = $_GET['type'] ?? '';
$search = $_GET['search'] ?? '';
$entities = $this->repository->getEntitiesFiltered($type, $search);
$stats = $this->repository->getEntityStats();
$this->view('semantic-explorer.entitaeten.index', [
'title' => 'Entitaeten',
'entities' => $entities,
'stats' => $stats,
'currentType' => $type,
'currentSearch' => $search,
]);
}
/**
* GET /semantic-explorer/entitaeten/{id}
* Entitaet-Details
*/
public function show(int $id): void
{
$entity = $this->repository->getEntity($id);
if ($entity === null) {
$this->notFound('Entitaet nicht gefunden');
}
$synonyms = $this->repository->getEntitySynonyms($id);
$outgoingRelations = $this->repository->getOutgoingRelations($id);
$incomingRelations = $this->repository->getIncomingRelations($id);
$chunks = $this->repository->getChunksForEntity($id);
$classifications = $this->repository->getEntityClassifications($id);
$this->view('semantic-explorer.entitaeten.show', [
'title' => $entity['name'],
'entity' => $entity,
'synonyms' => $synonyms,
'outgoingRelations' => $outgoingRelations,
'incomingRelations' => $incomingRelations,
'chunks' => $chunks,
'classifications' => $classifications,
]);
}
/**
* GET /semantic-explorer/entitaeten/new
*/
public function create(): void
{
$this->view('semantic-explorer.entitaeten.new', [
'title' => 'Neue Entitaet',
'types' => $this->repository->getEntityTypes(),
]);
}
/**
* POST /semantic-explorer/entitaeten
*/
public function store(): void
{
$input = json_decode(file_get_contents('php://input'), true);
$name = trim($input['name'] ?? '');
$type = trim($input['type'] ?? '');
$description = trim($input['description'] ?? '') ?: null;
if ($name === '' || $type === '') {
$this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400);
return;
}
try {
$id = $this->repository->createEntity($name, $type, $description);
$this->json(['success' => true, 'id' => $id]);
} catch (\Exception $e) {
$this->json(['success' => false, 'error' => $e->getMessage()], 500);
}
}
/**
* GET /semantic-explorer/entitaeten/{id}/edit
*/
public function edit(int $id): void
{
$entity = $this->repository->getEntity($id);
if ($entity === null) {
$this->notFound('Entitaet nicht gefunden');
}
$this->view('semantic-explorer.entitaeten.edit', [
'title' => 'Entitaet bearbeiten',
'entity' => $entity,
'types' => $this->repository->getEntityTypes(),
]);
}
/**
* POST /semantic-explorer/entitaeten/{id}
*/
public function update(int $id): void
{
$input = json_decode(file_get_contents('php://input'), true);
$name = trim($input['name'] ?? '');
$type = trim($input['type'] ?? '');
$description = trim($input['description'] ?? '') ?: null;
if ($name === '' || $type === '') {
$this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400);
return;
}
try {
$this->repository->updateEntity($id, $name, $type, $description);
$this->json(['success' => true]);
} catch (\Exception $e) {
$this->json(['success' => false, 'error' => $e->getMessage()], 500);
}
}
/**
* POST /semantic-explorer/entitaeten/{id}/delete
*/
public function delete(int $id): void
{
try {
$success = $this->repository->deleteEntity($id);
if ($success) {
$this->json(['success' => true]);
} else {
$this->json(['success' => false, 'error' => 'Entitaet hat noch Relationen'], 400);
}
} catch (\Exception $e) {
$this->json(['success' => false, 'error' => $e->getMessage()], 500);
}
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1986 |
18 |
modified |
6.5 KB |
2025-12-28 03:00 |
| 1714 |
17 |
modified |
5.5 KB |
2025-12-27 12:27 |
| 1713 |
16 |
modified |
5.0 KB |
2025-12-27 12:27 |
| 1094 |
15 |
modified |
5.0 KB |
2025-12-25 09:19 |
| 1093 |
14 |
modified |
5.0 KB |
2025-12-25 09:19 |
| 1092 |
13 |
modified |
5.0 KB |
2025-12-25 09:19 |
| 1091 |
12 |
modified |
5.0 KB |
2025-12-25 09:19 |
| 1090 |
11 |
modified |
5.0 KB |
2025-12-25 09:19 |
| 1089 |
10 |
modified |
5.1 KB |
2025-12-25 09:19 |
| 1088 |
9 |
modified |
5.1 KB |
2025-12-25 09:19 |
| 1087 |
8 |
modified |
5.1 KB |
2025-12-25 09:17 |
| 691 |
7 |
modified |
5.1 KB |
2025-12-23 07:52 |
| 613 |
6 |
modified |
5.2 KB |
2025-12-23 04:42 |
| 515 |
5 |
modified |
5.1 KB |
2025-12-22 15:48 |
| 514 |
4 |
modified |
5.0 KB |
2025-12-22 15:48 |
| 513 |
3 |
modified |
4.8 KB |
2025-12-22 15:48 |
| 302 |
2 |
modified |
4.7 KB |
2025-12-22 08:04 |
| 301 |
1 |
modified |
4.8 KB |
2025-12-22 08:04 |
← Zurück zur Übersicht