Added basket to core

This commit is contained in:
Kevin Frantz 2018-07-15 11:47:01 +02:00
parent 2ceaf0e515
commit 99f863e639
2 changed files with 38 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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;
}