Files
raby/provm/common/Basic/Controller.php

20 lines
608 B
PHP
Raw Normal View History

2020-02-27 19:09:54 -03:00
<?php
namespace ProVM\Common\Basic;
use Psr\Http\Message\ResponseInterface as Response;
use ProVM\Common\Definition\Controller as ControllerInterface;
abstract class Controller implements ControllerInterface {
public function withJSON(Response $response, string $data): Response {
$response->getBody()->write(json_encode($data));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus(201);
}
2020-04-07 15:37:21 -04:00
public function withRedirect(Response $response, string $uri): Response {
2020-02-27 19:09:54 -03:00
return $response
->withHeader('Location', $uri)
->withStatus(303);
}
}