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