diff --git a/src/controller/standart/Standart.php b/src/controller/standart/Standart.php index 8b42fdb..65b3ca6 100644 --- a/src/controller/standart/Standart.php +++ b/src/controller/standart/Standart.php @@ -2,6 +2,7 @@ namespace controller\standart; use controller\AbstractController; +use router\Link; /** * @@ -11,7 +12,32 @@ use controller\AbstractController; final class Standart extends AbstractController implements StandartInterface { public function homepage():void{ - $this->render('standart/homepage.html.twig'); + $this->render('standart/homepage.html.twig',['options'=>$this->getAllOptions()]); + } + + private function getAllOptions(){ + return [ + new Link([ + 'controller'=>'user', + 'action'=>'login' + ],'login'), + new Link([ + 'controller'=>'user', + 'action'=>'logout' + ],'logout'), + new Link([ + 'controller'=>'user', + 'action'=>'register' + ],'register'), + new Link([ + 'controller'=>'product', + 'action'=>'list' + ],'product list'), + new Link([ + 'controller'=>'order', + 'action'=>'basket' + ],'basket'), + ]; } } diff --git a/src/router/Url.php b/src/router/Link.php similarity index 53% rename from src/router/Url.php rename to src/router/Link.php index f548dd7..0a7668a 100644 --- a/src/router/Url.php +++ b/src/router/Link.php @@ -6,7 +6,7 @@ namespace router; * @author kevinfrantz * */ -class Url +class Link { /** * ArrayCollection would be nicer but I have to save time ;) @@ -14,19 +14,39 @@ class Url */ private $parameters; + /** + * + * @var string + */ + private $name; + + public function __construct(array $parameters=[],string $name = ''){ + $this->setParameters($parameters); + $this->setName($name); + } + public function setParameters(array $parameters):void{ $this->parameters = $parameters; } + public function setName(string $name):void{ + $this->name = $name; + } + + public function getName():string{ + return $this->name; + } + public function getUrl():string{ return "index.php".$this->getParameters(); } private function getParameters():string{ $parameters = '?'; - foreach ($parameters as $key=>$value){ + foreach ($this->parameters as $key=>$value){ $parameters .= $key.'='.$value.'&'; } + return $parameters; } } diff --git a/src/template/standart/homepage.html.twig b/src/template/standart/homepage.html.twig index 510a2e0..fd5ce3c 100644 --- a/src/template/standart/homepage.html.twig +++ b/src/template/standart/homepage.html.twig @@ -1,3 +1,13 @@ {% extends "frames/default.html.twig" %} {% block title %}Homepage{% endblock %} -{% block content %}Welcome to the online shop ;){% endblock %} +{% block content %} +

Welcome to the online shop!

+You have the following options: + +{% endblock %}