Cant brain right now.
This commit is contained in:
parent
3f54c010b6
commit
e42be2060f
2 changed files with 19 additions and 4 deletions
src
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue