Commit 7fb359a7 authored by Aldo's avatar Aldo 🐛

controle admin

parent c231ce15
......@@ -1559,16 +1559,16 @@
},
{
"name": "sensio/framework-extra-bundle",
"version": "v5.5.1",
"version": "v5.5.3",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
"reference": "dfc2c4df9f7d465a65c770e9feb578fe071636f7"
"reference": "98f0807137b13d0acfdf3c255a731516e97015de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/dfc2c4df9f7d465a65c770e9feb578fe071636f7",
"reference": "dfc2c4df9f7d465a65c770e9feb578fe071636f7",
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/98f0807137b13d0acfdf3c255a731516e97015de",
"reference": "98f0807137b13d0acfdf3c255a731516e97015de",
"shasum": ""
},
"require": {
......@@ -1633,7 +1633,7 @@
"annotations",
"controllers"
],
"time": "2019-10-16T18:54:45+00:00"
"time": "2019-12-27T08:57:19+00:00"
},
{
"name": "symfony/apache-pack",
......
......@@ -8,14 +8,12 @@ use App\Form\OrderType;
use App\Entity\OrderLine;
use App\Entity\OrderStatus;
use App\Entity\ShoppingCart;
use App\Repository\OrderRepository;
use App\Controller\Front\UserController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
/**
* @Route("/order", name="order_")
......@@ -191,6 +189,7 @@ class OrderController extends AbstractController
/**
* @Route("/{id}", name="order_delete", methods={"DELETE"}, requirements={"id":"\d+"})
* @IsGranted("ROLE_ADMIN")
*/
public function delete(Request $request, Order $order): Response
{
......
......@@ -6,12 +6,14 @@ use App\Entity\Order;
use App\Entity\Sandwich;
use App\Entity\OrderLine;
use App\Entity\ShoppingCart;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* @Route("/order/line", name="order_line_")
*/
......@@ -129,9 +131,11 @@ class OrderLineController extends AbstractController
/**
* @Route("/{id}", name="delete", methods={"DELETE"})
* @IsGranted("ROLE_ADMIN")
*/
public function delete(Request $request, OrderLine $orderLine): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
if ($this->isCsrfTokenValid('delete' . $orderLine->getId(), $request->request->get('_token'))) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($orderLine);
......
......@@ -23,10 +23,12 @@ class SandwichController extends AbstractController
/**
* @Route("/", name="index", methods={"GET"})
*/
public function index(SandwichRepository $sandwichRepository): Response
public function index(SandwichRepository $sandwichRepository, $aLaCarte = true): Response
{
$aLaCarte ? $sandwiches = $sandwichRepository->findBy(['aLaCarte' => true]) : $sandwiches = $sandwichRepository->findAll();
return $this->render('front/sandwich/index.html.twig', [
'sandwiches' => $sandwichRepository->findBy(['aLaCarte' => true]),
'sandwiches' => $sandwiches,
]);
}
......
......@@ -5,9 +5,9 @@
{% block body %}
{# {{ dump(cart) }}{{ dump(cart.orderLine) }}{% for orderLine in cart.orderLine %}{{ dump(orderLine) }}{% endfor %} #}
{# {{ dump(cart) }}{{ dump(cart.orderLine) }} {% for orderLine in cart.orderLine %} {{ dump(orderLine) }} {% endfor %} #}
{% if cart is not empty %}
{% if cart.orderLine is not empty %}
{% set title = 'Shopping cart' %}
{% if not isComponent %}
......@@ -53,8 +53,13 @@
{% else %}
{% if not isComponent %}
<div class="alert alert-info" role="alert">
Your cart is empty
Your shopping cart is empty.
<br>
Go to
<a href="{{ path('sandwich_index') }}">sandwich index</a>
to buy some delicious sandwiches
</div>
{% endif %}
{# notification on sanwich index #}
{% endif %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment