Browse Source

src: Insert database to controller

master
Elis Hirwing 3 years ago
parent
commit
5a8e708e4d
Signed by: etu GPG Key ID: D57EFA625C9A925F
  1. 2
      public/index.php
  2. 7
      src/Etu/Controller/Inventory.php

2
public/index.php

@ -52,7 +52,7 @@ $container['db'] = function (Slim\Container $c) {
* Set up controllers
*/
$container[InventoryController::class] = function (Slim\Container $c) {
return new InventoryController($c['logger']);
return new InventoryController($c['logger'], $c['db']);
};
$app->run();

7
src/Etu/Controller/Inventory.php

@ -2,16 +2,21 @@
namespace Etu\Controller;
use Monolog\Logger;
use PDO;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class Inventory
{
/** @var PDO */
private $db;
/** @var Logger */
private $logger;
public function __construct(Logger $logger)
public function __construct(Logger $logger, PDO $db)
{
$this->db = $db;
$this->logger = $logger;
}

Loading…
Cancel
Save