1
0
mirror of synced 2025-01-09 18:47:12 +03:00
DeliveryModuleBundle/Command/Traits/AccountAwareTrait.php

25 lines
741 B
PHP
Raw Normal View History

2020-08-03 15:54:38 +03:00
<?php
namespace RetailCrm\DeliveryModuleBundle\Command\Traits;
use Doctrine\ORM\Tools\Pagination\Paginator;
trait AccountAwareTrait
{
protected function getAccounts(int $accountId = null): \ArrayIterator
{
if (null === $accountId) {
return new \ArrayIterator([$this->accountManager->find($accountId)]);
}
$accountQuery = $this->accountManager->getRepository()->createQueryBuilder('account')
->where('account.active = true')
->andWhere('account.freeze != true')
->addOrderBy('account.id')
->getQuery()
->setFirstResult(0)
->setMaxResults(100)
;
return (new Paginator($accountQuery))->getIterator();
}
}