Files
MediaCollectorLibary/app/Controllers/Controller.php
Lars Behrends 929ee43001 first commit
2025-10-17 13:29:28 +02:00

26 lines
585 B
PHP

<?php
namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
abstract class Controller
{
protected $view;
public function __construct(Twig $view)
{
$this->view = $view;
}
protected function json(Response $response, $data, int $status = 200): Response
{
$response->getBody()->write(json_encode($data));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus($status);
}
}