14 lines
360 B
PHP
14 lines
360 B
PHP
<?php
|
|
namespace ProVM\Common\Define\Controller;
|
|
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
trait JSON {
|
|
public function withJson(Response $response, $data, $status_code = 200) {
|
|
$response->getBody()->write(json_encode($data));
|
|
return $response
|
|
->withHeader('Content-Type', 'application/json')
|
|
->withStatus($status_code);
|
|
}
|
|
}
|