<?php
namespace BitBag\OpenMarketplace\Controller\Bikers;
use FOS\RestBundle\View\View;
use Sylius\Bundle\OrderBundle\Controller\OrderController as BaseOrderController;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;
use Webmozart\Assert\Assert;
final class SecurityWidgetController extends BaseOrderController
{
// public function __construct(private EngineInterface|Environment $templatingEngine)
// {
// }
public function renderAction(Request $request, string $urlpath): Response
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$cart = $this->getCurrentCart();
$d = 0;
if (null !== $cart->getId()) {
$orderRepository = $this->getOrderRepository();
Assert::isInstanceOf($orderRepository, OrderRepositoryInterface::class);
$cart = $orderRepository->findCartForSummary($cart->getId());
$items = $cart->getItems();
$d = count($items);
}
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create($cart));
}
return $this->render('@SyliusShop/Menu/_security.html.twig', [
'cart' => $cart,
'count' => $d,
'urlpath' => $urlpath,
]);
}
}