<?php

namespace App\Repository\Blog;

use App\Core\Repository\RepositoryQuery;
use Knp\Component\Pager\PaginatorInterface;

/**
 * class CommentRepositoryQuery.
 *
 * @author Simon Vieille <simon@deblan.fr>
 */
class CommentRepositoryQuery extends RepositoryQuery
{
    public function __construct(CommentRepository $repository, PaginatorInterface $paginator)
    {
        parent::__construct($repository, 'c', $paginator);
    }

    protected function filterHandler(string $name, $value)
    {
        if ('post' === $name) {
            $this
                ->andWhere('.post = :postId')
                ->setParameter(':postId', $value->getId())
            ;
        }
    }
}
