| @@ 8-44 (lines=37) @@ | ||
| 5 | use Doctrine\ODM\MongoDB\DocumentManager; |
|
| 6 | use Dtc\GridBundle\Grid\Source\DocumentGridSource; |
|
| 7 | ||
| 8 | class LiveJobGridSource extends DocumentGridSource |
|
| 9 | { |
|
| 10 | protected $jobManager; |
|
| 11 | ||
| 12 | public function getId() |
|
| 13 | { |
|
| 14 | return 'dtc_queue.grid_source.live_jobs.odm'; |
|
| 15 | } |
|
| 16 | ||
| 17 | public function __construct(JobManager $jobManager) |
|
| 18 | { |
|
| 19 | $this->jobManager = $jobManager; |
|
| 20 | ||
| 21 | /** @var DocumentManager $documentManager */ |
|
| 22 | $documentManager = $jobManager->getObjectManager(); |
|
| 23 | parent::__construct($documentManager, $jobManager->getObjectName()); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function getColumns() |
|
| 27 | { |
|
| 28 | if ($columns = parent::getColumns()) { |
|
| 29 | return $columns; |
|
| 30 | } |
|
| 31 | $this->autoDiscoverColumns(); |
|
| 32 | ||
| 33 | return parent::getColumns(); |
|
| 34 | } |
|
| 35 | ||
| 36 | protected function getQueryBuilder() |
|
| 37 | { |
|
| 38 | $builder = $this->jobManager->getJobQueryBuilder(); |
|
| 39 | $builder->limit($this->limit); |
|
| 40 | $builder->skip($this->offset); |
|
| 41 | ||
| 42 | return $builder; |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 8-43 (lines=36) @@ | ||
| 5 | use Doctrine\ORM\EntityManager; |
|
| 6 | use Dtc\GridBundle\Grid\Source\EntityGridSource; |
|
| 7 | ||
| 8 | class LiveJobGridSource extends EntityGridSource |
|
| 9 | { |
|
| 10 | protected $jobManager; |
|
| 11 | ||
| 12 | public function getId() |
|
| 13 | { |
|
| 14 | return 'dtc_queue.grid_source.live_jobs.orm'; |
|
| 15 | } |
|
| 16 | ||
| 17 | public function __construct(JobManager $jobManager) |
|
| 18 | { |
|
| 19 | $this->jobManager = $jobManager; |
|
| 20 | /** @var EntityManager $entityManager */ |
|
| 21 | $entityManager = $jobManager->getObjectManager(); |
|
| 22 | parent::__construct($entityManager, $jobManager->getObjectName()); |
|
| 23 | } |
|
| 24 | ||
| 25 | public function getColumns() |
|
| 26 | { |
|
| 27 | if ($columns = parent::getColumns()) { |
|
| 28 | return $columns; |
|
| 29 | } |
|
| 30 | $this->autoDiscoverColumns(); |
|
| 31 | ||
| 32 | return parent::getColumns(); |
|
| 33 | } |
|
| 34 | ||
| 35 | protected function getQueryBuilder() |
|
| 36 | { |
|
| 37 | $queryBuilder = $this->jobManager->getJobQueryBuilder(); |
|
| 38 | $queryBuilder->setFirstResult($this->offset) |
|
| 39 | ->setMaxResults($this->limit); |
|
| 40 | ||
| 41 | return $queryBuilder; |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||