<?php
namespace App\Components;
use App\Dto\CartItem;
use App\Service\ShoppingCartService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;
#[AsLiveComponent('shopping_cart')]
final class ShoppingCartComponent extends AbstractController {
use DefaultActionTrait;
/** @var ShoppingCartService */
private $shoppingCartService;
public function __construct(ShoppingCartService $shoppingCartService) {
$this->shoppingCartService = $shoppingCartService;
}
/**
* @return array<int, CartItem>
*/
public function getCartItems(): array {
return $this->shoppingCartService->getCartItems();
}
public function getNumberOfItems(): int {
return $this->shoppingCartService->getNumberOfItems();
}
public function getTotalPrice(): float {
return $this->shoppingCartService->getTotalPrice();
}
public function getTotalRecurringPrice(): float {
return $this->shoppingCartService->getTotalRecurringPrice();
}
}