<?php

namespace Lc\CaracoleBundle\Repository\File;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class DocumentRepositoryQuery extends AbstractRepositoryQuery
{
    use SectionRepositoryQueryTrait;

    public function __construct(DocumentRepository $repository, PaginatorInterface $paginator)
    {
        parent::__construct($repository, 'r', $paginator);
    }

    public function filterByType($type)
    {
        return $this->andWhereEqual('type', $type);
    }

    public function filterByBuyerAddress(AddressInterface $buyerAddress)
    {
        return $this
                ->andWhere('.buyerAddress = :buyerAddress')
                ->setParameter('buyerAddress', $buyerAddress);
    }
}