mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-22 10:11:04 +01:00
Added basket to core
This commit is contained in:
parent
2ceaf0e515
commit
99f863e639
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace core;
|
||||
|
||||
use entity\order\Order;
|
||||
use entity\user\UserInterface;
|
||||
|
||||
/**
|
||||
@ -39,6 +40,12 @@ final class Core implements CoreInterface
|
||||
*/
|
||||
private $database;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Order
|
||||
*/
|
||||
private $basket;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->initTwig();
|
||||
@ -86,5 +93,24 @@ final class Core implements CoreInterface
|
||||
{
|
||||
$_SESSION['user'] = $this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \core\CoreInterface::getBasket()
|
||||
*/
|
||||
public function getBasket(): Order
|
||||
{
|
||||
return $this->basket;
|
||||
}
|
||||
|
||||
/**
|
||||
* The basket is depending on the session
|
||||
* {@inheritDoc}
|
||||
* @see \core\CoreInterface::setBasket()
|
||||
*/
|
||||
public function setBasket(Order $basket): void
|
||||
{
|
||||
$_SESSION['basket'] = $this->basket = $basket;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,20 +2,24 @@
|
||||
namespace core;
|
||||
|
||||
use entity\user\UserInterface;
|
||||
use entity\order\Order;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*
|
||||
*/
|
||||
interface CoreInterface
|
||||
{
|
||||
public function getDatabase():\PDO;
|
||||
|
||||
public function getTwig():\Twig_Environment;
|
||||
|
||||
public function getUser():?UserInterface;
|
||||
|
||||
public function setUser(?UserInterface $user = null):void;
|
||||
}
|
||||
|
||||
public function getTwig():\Twig_Environment;
|
||||
|
||||
public function getUser():?UserInterface;
|
||||
|
||||
public function setUser(?UserInterface $user = null):void;
|
||||
|
||||
public function getBasket():Order;
|
||||
|
||||
public function setBasket(Order $basket):void;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user