mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-01 00:53:10 +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,6 +2,7 @@
|
||||
namespace core;
|
||||
|
||||
use entity\user\UserInterface;
|
||||
use entity\order\Order;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -17,5 +18,8 @@ interface CoreInterface
|
||||
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