Avoid creating a new Twig instance, get it from the request set up in the middleware

This commit is contained in:
Dave Smith-Hayes 2024-12-03 16:00:27 +00:00
parent f45c5a6551
commit d45800cfc4
4 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,7 @@ abstract class Controller
$this->response = $response; $this->response = $response;
$this->args = $args; $this->args = $args;
$this->routeContext = RouteContext::fromRequest($this->request); $this->routeContext = RouteContext::fromRequest($this->request);
$this->view = Twig::fromRequest($request); $this->view = $this->request->getAttribute('view');
return $this->handle(); return $this->handle();
} }

View File

@ -2,11 +2,14 @@
namespace Slovocast\Infrastructure\Api\Database; namespace Slovocast\Infrastructure\Api\Database;
use ReturnTypeWillChange;
interface DatabaseHandlerInterface interface DatabaseHandlerInterface
{ {
/** /**
* @return mixed The return must be an active connection to a database. * @return mixed The return must be an active connection to a database.
*/ */
#[ReturnTypeWillChange]
public function getConnection(); public function getConnection();
/** /**

View File

@ -33,7 +33,7 @@ class DatabaseHandler implements DatabaseHandlerInterface
/** /**
* @return PDO For this particular Handler we will return the PDO object * @return PDO For this particular Handler we will return the PDO object
*/ */
public function getConnection() public function getConnection(): PDO
{ {
return $this->handle; return $this->handle;
} }

View File

@ -3,7 +3,6 @@
namespace Slovocast; namespace Slovocast;
use League\Config\Configuration; use League\Config\Configuration;
use Odan\Session\Middleware\SessionStartMiddleware;
use Odan\Session\SessionInterface; use Odan\Session\SessionInterface;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;