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