45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Twig\Components;
|
|
|
|
use App\Download\Framework\Repository\DownloadRepository;
|
|
use App\Util\Paginator;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
|
use Symfony\UX\LiveComponent\Attribute\LiveAction;
|
|
use Symfony\UX\LiveComponent\Attribute\LiveArg;
|
|
use Symfony\UX\LiveComponent\Attribute\LiveProp;
|
|
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
|
|
|
#[AsLiveComponent]
|
|
final class DownloadList extends AbstractController
|
|
{
|
|
use DefaultActionTrait;
|
|
|
|
use PaginateTrait;
|
|
|
|
#[LiveProp(writable: true)]
|
|
public string $term = "";
|
|
|
|
#[LiveProp(writable: true)]
|
|
public string $type;
|
|
|
|
#[LiveProp(writable: true)]
|
|
public bool $isWidget = true;
|
|
|
|
public function __construct(
|
|
private readonly DownloadRepository $downloadRepository,
|
|
) {}
|
|
|
|
public function getDownloads()
|
|
{
|
|
if ($this->type === "active") {
|
|
return $this->downloadRepository->getActivePaginated($this->getUser(), $this->pageNumber, $this->perPage, $this->term);
|
|
} elseif ($this->type === "complete") {
|
|
return $this->downloadRepository->getCompletePaginated($this->getUser(), $this->pageNumber, $this->perPage, $this->term);
|
|
}
|
|
|
|
return [];
|
|
}
|
|
}
|