Ensured a generic template is used to render generic 404 errors, and a more specific one to render 'invalid short url' errors

This commit is contained in:
Alejandro Celaya
2017-10-13 12:22:19 +02:00
parent c12e13dfd7
commit ea76092681
11 changed files with 86 additions and 24 deletions

View File

@@ -3,13 +3,14 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Util;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\Stream;
use Zend\Stdlib\ArrayUtils;
trait ResponseUtilsTrait
{
protected function generateDownloadFileResponse($filePath)
protected function generateDownloadFileResponse(string $filePath): ResponseInterface
{
return $this->generateBinaryResponse($filePath, [
'Content-Disposition' => 'attachment; filename=' . basename($filePath),
@@ -21,12 +22,12 @@ trait ResponseUtilsTrait
]);
}
protected function generateImageResponse($imagePath)
protected function generateImageResponse(string $imagePath): ResponseInterface
{
return $this->generateBinaryResponse($imagePath);
}
protected function generateBinaryResponse($path, $extraHeaders = [])
protected function generateBinaryResponse(string $path, array $extraHeaders = []): ResponseInterface
{
$body = new Stream($path);
return new Response($body, 200, ArrayUtils::merge([