Cant brain right now.

This commit is contained in:
Greyscale 2024-05-25 13:03:02 +01:00
parent 3f54c010b6
commit e42be2060f
2 changed files with 19 additions and 4 deletions

View file

@ -13,17 +13,14 @@ use Slim\Exception\HttpNotFoundException;
abstract class Action
{
protected LoggerInterface $logger;
protected Request $request;
protected Response $response;
protected array $args;
public function __construct(LoggerInterface $logger)
public function __construct(protected LoggerInterface $logger)
{
$this->logger = $logger;
$this->response = new \Slim\Psr7\Response();
}
@ -67,4 +64,11 @@ abstract class Action
->withHeader('Content-Type', 'application/json')
->withStatus($payload->getStatusCode());
}
protected function redirect(string $redirectUrl) : Response
{
return $this->response
->withHeader('Location', $redirectUrl)
->withStatus(302);
}
}

View file

@ -58,4 +58,15 @@ class EnvironmentService
$this->get('HTTP_HOST')
);
}
public function getPublicPath(): string
{
return $this->get('REQUEST_URI');
}
public function getPublicUrl(): string
{
return $this->getPublicHostname() . $this->getPublicPath();
}
}