From d966cbc35d4fdecf586e2fc52a1d0ba1656a5ca6 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 14 Jul 2018 18:50:47 +0200 Subject: [PATCH] Added draft for get routing --- src/controller/AbstractController.php | 7 ++ src/controller/order/Order.php | 25 ++++++ src/controller/order/OrderInterface.php | 2 +- src/controller/product/Product.php | 20 +++++ src/controller/product/ProductInterface.php | 4 +- src/controller/standart/Standart.php | 2 +- src/controller/standart/StandartInterface.php | 13 +++ src/controller/user/User.php | 21 +++++ src/router/Router.php | 86 ++++++++++++------- 9 files changed, 144 insertions(+), 36 deletions(-) create mode 100644 src/controller/order/Order.php create mode 100644 src/controller/product/Product.php create mode 100644 src/controller/standart/StandartInterface.php create mode 100644 src/controller/user/User.php diff --git a/src/controller/AbstractController.php b/src/controller/AbstractController.php index a82fdfc..f2de7fe 100644 --- a/src/controller/AbstractController.php +++ b/src/controller/AbstractController.php @@ -15,8 +15,15 @@ abstract class AbstractController */ protected $core; + /** + * + * @var array + */ + protected $post; + public function __construct(CoreInterface $core){ $this->core = $core; + $this->post = $_POST; } protected function render(string $template,array $variables=[]):void{ diff --git a/src/controller/order/Order.php b/src/controller/order/Order.php new file mode 100644 index 0000000..043c924 --- /dev/null +++ b/src/controller/order/Order.php @@ -0,0 +1,25 @@ +render('standart/homepage.html.twig'); diff --git a/src/controller/standart/StandartInterface.php b/src/controller/standart/StandartInterface.php new file mode 100644 index 0000000..9681e2a --- /dev/null +++ b/src/controller/standart/StandartInterface.php @@ -0,0 +1,13 @@ +post['route']){ - $this->postRouting(); + if ($this->get) { + switch ($this->get['controller']) { + case 'user': + $userController = new User(); + switch ($this->get['action']) { + case 'login': + return $userController->login(); + case 'logout': + return $userController->logout(); + case 'register': + return $userController->register(); + } + case 'product': + $productController = new Product(); + switch ($this->get['action']) { + case 'list': + return $productController->list(); + case 'color': + return $productController->colorFilter($this->get['color']); + } + case 'order': + $orderController = new Order($this->core); + switch ($this->get['action']){ + case 'store': + return $orderController->store(); + case 'basket': + return $orderController->basket(); + case 'payment': + return $orderController->selectPaymentMethod(); + case 'add-product': + return $orderController->addProduct(); + } + } + } else { + $standartController = new Standart($this->core); + return $standartController->homepage(); } - if($this->get['router']){ - $this->getRouting(); - }else{ - $standart = new Standart($this->core); - $standart->homepage(); - } - } - - private function postRouting():void{ - - } - - private function getRouting():void{ - + throw new \Exception('Route not found!'); } - public function setGet(array $get):void + public function setGet(array $get): void { $this->get = $get; } - public function setCore(CoreInterface $core):void + public function setCore(CoreInterface $core): void { $this->core = $core; } - - public function setPost(array $post): void - { - $this->post = $post; - } - }