mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
26 lines
585 B
PHP
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);
|
|
}
|
|
}
|