mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-22 10:11:04 +01:00
Optimized twig and payment methods
This commit is contained in:
parent
18382d6633
commit
3fdcd47e9c
@ -6,6 +6,7 @@ use core\CoreInterface;
|
|||||||
use repository\order\OrderInterface as OrderRepositoryInterface;
|
use repository\order\OrderInterface as OrderRepositoryInterface;
|
||||||
use repository\product\ProductInterface as ProductRepositoryInterface;
|
use repository\product\ProductInterface as ProductRepositoryInterface;
|
||||||
use repository\product\Product as ProductRepository;
|
use repository\product\Product as ProductRepository;
|
||||||
|
use entity\payment\AbstractPayment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -47,7 +48,8 @@ final class Order extends AbstractDefaultController implements OrderInterface
|
|||||||
$this->postRoutine();
|
$this->postRoutine();
|
||||||
}
|
}
|
||||||
$this->render('order/basket.html.twig', [
|
$this->render('order/basket.html.twig', [
|
||||||
'basket' => $this->core->getBasket()
|
'basket' => $this->core->getBasket(),
|
||||||
|
'payment_methods'=>AbstractPayment::getPaymentMethods(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +59,5 @@ final class Order extends AbstractDefaultController implements OrderInterface
|
|||||||
$this->addProduct();
|
$this->addProduct();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectPaymentMethod(): void
|
|
||||||
{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,4 @@ namespace controller\order;
|
|||||||
interface OrderInterface
|
interface OrderInterface
|
||||||
{
|
{
|
||||||
public function basket():void;
|
public function basket():void;
|
||||||
|
|
||||||
public function selectPaymentMethod():void;
|
|
||||||
}
|
}
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace entity\payment;
|
namespace entity\payment;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use entity\payment\method1\Method1;
|
||||||
|
use entity\payment\method2\Method2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -8,5 +12,16 @@ namespace entity\payment;
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractPayment implements PaymentInterface
|
abstract class AbstractPayment implements PaymentInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Returns all available Payment methods
|
||||||
|
* @return ArrayCollection
|
||||||
|
*/
|
||||||
|
public static function getPaymentMethods(): ArrayCollection
|
||||||
|
{
|
||||||
|
return new ArrayCollection([
|
||||||
|
'method1'=>new Method1(),
|
||||||
|
'method2'=>new Method2()
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,20 @@ basket
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{product.id}}</td>
|
<td>{{product.id}}</td>
|
||||||
<td>{{product.name}}</td>
|
<td>{{product.name}}</td>
|
||||||
<td>{{product.price.netto.float}}</td>
|
<td>{{product.price.netto.float}} {{product.price.netto.symbol}}</td>
|
||||||
<td>{{product.price.tax}}</td>
|
<td>{{product.price.tax}}</td>
|
||||||
<td>{{product.price.gross.float}}</td>
|
<td>{{product.price.gross.float}} {{product.price.gross.symbol}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
<form method="post">
|
||||||
|
<select class="form-control form-control-lg">
|
||||||
|
<option value="" disabled selected>Payment method</option>
|
||||||
|
{% for key,payment in payment_methods %}
|
||||||
|
<option value="{{ key }}">{{ payment.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<input type="hidden" name="store" value="1" />
|
||||||
|
<input type="submit" class="btn btn-primary" value="Order" />
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -2,12 +2,5 @@
|
|||||||
{% block title %}Homepage{% endblock %}
|
{% block title %}Homepage{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Welcome to the online shop!</h2>
|
<h2>Welcome to the online shop!</h2>
|
||||||
You have the following options:
|
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Signs%2C_signs_and_more_signs_%282504183343%29.jpg/1280px-Signs%2C_signs_and_more_signs_%282504183343%29.jpg" />
|
||||||
<ul>
|
|
||||||
{% for option in menu_items %}
|
|
||||||
<li>
|
|
||||||
<a href="{{option.getUrl}}">{{option.getName}}</a>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user