Some extra minor improvements

This commit is contained in:
Alejandro Celaya
2019-11-02 19:08:07 +01:00
parent 7030138ff4
commit 9abaa243e0
4 changed files with 9 additions and 13 deletions

View File

@@ -7,14 +7,10 @@ namespace Shlinkio\Shlink\Core\Action;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Options;
use Zend\Diactoros\Response\RedirectResponse;
class RedirectAction extends AbstractTrackingAction
{
/** @var Options\NotFoundRedirectOptions */
private $redirectOptions;
protected function createSuccessResp(string $longUrl): Response
{
// Return a redirect response to the long URL.

View File

@@ -23,8 +23,8 @@ use function rtrim;
class NotFoundHandler implements RequestHandlerInterface
{
public const NOT_FOUND_ERROR_TEMPLATE = 'ShlinkCore::error/404';
public const INVALID_SHORT_CODE_ERROR_TEMPLATE = 'ShlinkCore::invalid-short-code';
public const NOT_FOUND_TEMPLATE = 'ShlinkCore::error/404';
public const INVALID_SHORT_CODE_TEMPLATE = 'ShlinkCore::invalid-short-code';
/** @var TemplateRendererInterface */
private $renderer;
@@ -72,10 +72,8 @@ class NotFoundHandler implements RequestHandlerInterface
], $status);
}
$notFoundTemplate = $routeResult->isFailure()
? self::NOT_FOUND_ERROR_TEMPLATE
: self::INVALID_SHORT_CODE_ERROR_TEMPLATE;
return new Response\HtmlResponse($this->renderer->render($notFoundTemplate), $status);
$template = $routeResult->isFailure() ? self::NOT_FOUND_TEMPLATE : self::INVALID_SHORT_CODE_TEMPLATE;
return new Response\HtmlResponse($this->renderer->render($template), $status);
}
private function createRedirectResponse(RouteResult $routeResult, UriInterface $uri): ?ResponseInterface