Backup #1672

ID1672
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Controller/Api/ContentController.php
Version5
Typ modified
Größe1.8 KB
Hash49d42357afd4bede306bfc70aafdff994231fce06bd458e3a79cb943069b4203
Datum2025-12-27 11:43:58
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace Controller\Api;

// @responsibility: REST-API für Content-Aufträge

use Domain\Repository\ContentRepositoryInterface;
use Framework\Controller;

class ContentController extends Controller
{
    private ContentRepositoryInterface $repository;

    public function __construct(ContentRepositoryInterface $repository)
    {
        $this->repository = $repository;
    }

    public function update(int $id): void
    {
        try {
            $order = $this->repository->findOrder($id);

            if ($order === null) {
                $this->json(['success' => false, 'error' => 'Auftrag nicht gefunden'], 404);

                return;
            }

            $input = $this->getJsonInput();

            if (!isset($input['title']) || trim((string) $input['title']) === '') {
                $this->json(['success' => false, 'error' => 'Titel ist erforderlich'], 400);

                return;
            }

            if (!isset($input['briefing']) || trim((string) $input['briefing']) === '') {
                $this->json(['success' => false, 'error' => 'Briefing ist erforderlich'], 400);

                return;
            }

            $this->repository->updateOrder($id, [
                'title' => $input['title'],
                'briefing' => $input['briefing'],
                'author_profile_id' => $input['author_profile_id'] ?? null,
                'contract_id' => $input['contract_id'] ?? null,
                'structure_id' => $input['structure_id'] ?? null,
            ]);

            $updatedOrder = $this->repository->findOrder($id);

            $this->json([
                'success' => true,
                'data' => $updatedOrder,
            ]);
        } catch (\Exception $e) {
            $this->jsonError($e->getMessage());
        }
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
2067 6 modified 2.4 KB 2025-12-28 23:30
1672 5 modified 1.8 KB 2025-12-27 11:43
1274 4 modified 1.8 KB 2025-12-25 12:52
701 3 modified 1.7 KB 2025-12-23 07:53
623 2 modified 1.7 KB 2025-12-23 04:43
592 1 modified 1.7 KB 2025-12-23 04:25

← Zurück zur Übersicht