Eigene Compat-Controller (Api/Legacy) fuer die 5 real genutzten
/service-Endpoints (Prod-Log-Beleg): Company-/Kontakt-Create (liefen
410!), PM-Create, Bild-Upload, published-only-GET — verschachtelte
Alt-Params, 201+Location+{}, Alt-Fehlerformat, Hit-Zaehlung,
Legacy-Land-Mapping.
- Anlegen = Einreichen (Alt-Verhalten); Sofort-Publish via neuer
Permission api:immediate-publication (WS-7: connektar zuweisen)
- Admin-Schalter 'KI-Pruefung Legacy-API' (app_settings-Tabelle,
Toggle auf /admin/press-releases): an = review + KI-Routing
- Admin-PM-Liste: KI-Spalte (Ampel-Badge) + manueller Pruef-Button
ohne Routing fuer ungepruefte PMs
- Mails bei API-Einlieferern an Pressekontakt, sonst Firmen-Mail,
Fallback Einlieferer (User-Entscheidung 10.07.)
- Tests: LegacyServiceParityTest (connektar-Flow end-to-end);
Suite 1182 gruen
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Legacy;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
/**
|
|
* Response-Konventionen der Alt-API (Symfony, tnHttpError-Templates):
|
|
* Erfolg beim Anlegen = 201 + Location-Header + Body {};
|
|
* Fehler = {"global_errors":[…]} bzw. 422 zusätzlich mit "field_errors".
|
|
* Vertrag dokumentiert in dev/release/api-legacy-paritaet.md §1.
|
|
*/
|
|
trait RespondsLikeLegacyApi
|
|
{
|
|
protected function legacyCreated(string $locationUrl): JsonResponse
|
|
{
|
|
return response()->json((object) [], 201)->header('Location', $locationUrl);
|
|
}
|
|
|
|
protected function legacyError(int $status, array $globalErrors): JsonResponse
|
|
{
|
|
return response()->json(['global_errors' => $globalErrors], $status);
|
|
}
|
|
|
|
protected function legacyValidationError(ValidationException $exception): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'global_errors' => [],
|
|
'field_errors' => $exception->errors(),
|
|
], 422);
|
|
}
|
|
|
|
/**
|
|
* Legacy-Land (country.id der Altportale) → ISO-Code des neuen Systems.
|
|
* Häufigste IDs aus dem Prod-Snapshot; unbekannte → null (Feld leer).
|
|
*/
|
|
protected function legacyCountryCode(mixed $legacyCountryId): ?string
|
|
{
|
|
return match ((int) $legacyCountryId) {
|
|
177 => 'DE',
|
|
80 => 'AT',
|
|
196 => 'CH',
|
|
229 => 'US',
|
|
30 => 'GB',
|
|
165 => 'FR',
|
|
78 => 'IT',
|
|
2 => 'NL',
|
|
47 => 'ES',
|
|
108 => 'CY',
|
|
115 => 'LI',
|
|
117 => 'LU',
|
|
15 => 'AU',
|
|
89 => 'CA',
|
|
default => null,
|
|
};
|
|
}
|
|
}
|