From 99f863e639ce9fb4b7457ca1b903222c58eb734c Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 15 Jul 2018 11:47:01 +0200 Subject: [PATCH] Added basket to core --- src/core/Core.php | 26 ++++++++++++++++++++++++++ src/core/CoreInterface.php | 20 ++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/core/Core.php b/src/core/Core.php index 6d8eb0a..8b4e9f8 100644 --- a/src/core/Core.php +++ b/src/core/Core.php @@ -1,6 +1,7 @@ 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; + } } diff --git a/src/core/CoreInterface.php b/src/core/CoreInterface.php index 30b14f8..3ce8b82 100644 --- a/src/core/CoreInterface.php +++ b/src/core/CoreInterface.php @@ -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; +}