for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace App\Service;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Yiisoft\Http\Header;
use Yiisoft\Http\Status;
use Yiisoft\Router\UrlGeneratorInterface;
final class WebControllerService
{
private ResponseFactoryInterface $responseFactory;
private UrlGeneratorInterface $urlGenerator;
public function __construct(ResponseFactoryInterface $responseFactory, UrlGeneratorInterface $urlGenerator)
$this->responseFactory = $responseFactory;
$this->urlGenerator = $urlGenerator;
}
public function getRedirectResponse(string $url): ResponseInterface
return $this->responseFactory
->createResponse(Status::FOUND)
->withHeader(Header::LOCATION, $this->urlGenerator->generate($url));
public function getNotFoundResponse(): ResponseInterface
return $this->responseFactory->createResponse(Status::NOT_FOUND);