mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-12-22 23:25:03 +01:00
Listed all options
This commit is contained in:
parent
5c5eb64fd8
commit
f938f70e78
@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,13 @@
|
||||
{% extends "frames/default.html.twig" %}
|
||||
{% block title %}Homepage{% endblock %}
|
||||
{% block content %}Welcome to the online shop ;){% endblock %}
|
||||
{% block content %}
|
||||
<h2>Welcome to the online shop!</h2>
|
||||
You have the following options:
|
||||
<ul>
|
||||
{% for option in options %}
|
||||
<li>
|
||||
<a href="{{option.getUrl}}">{{option.getName}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user