46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Core\Repository\RepositoryQuery;
|
|
use App\Entity\ThemeType;
|
|
use App\Repository\ConferenceRepository as Repository;
|
|
use Knp\Component\Pager\PaginatorInterface;
|
|
|
|
class ConferenceRepositoryQuery extends RepositoryQuery
|
|
{
|
|
public function __construct(Repository $repository, PaginatorInterface $paginator)
|
|
{
|
|
parent::__construct($repository, 'c', $paginator);
|
|
}
|
|
|
|
public function withThemeType(?ThemeType $themeType): self
|
|
{
|
|
if (!$themeType) {
|
|
return $this;
|
|
}
|
|
|
|
$keyId = 'id'.mt_rand();
|
|
|
|
return $this
|
|
->andWhere('.themeType = :'.$keyId)
|
|
->setParameter($keyId, $themeType->getId())
|
|
;
|
|
}
|
|
|
|
protected function filterHandler(string $name, $value)
|
|
{
|
|
if ('themeType' === $name) {
|
|
return $this->withThemeType($value);
|
|
}
|
|
}
|
|
|
|
public function latest(int $max = 5)
|
|
{
|
|
return $this
|
|
->addOrderBy('.date', 'DESC')
|
|
->setMaxResults($max)
|
|
;
|
|
}
|
|
}
|