dao = $dao; } public function getCount(): int { return $this->dao->getCount($this); } /** * @return Collection */ public function getIds(): Collection { return $this->dao->getIds($this); } /** * @copydoc DAO::getMany() * @return LazyCollection */ public function getMany(): LazyCollection { return $this->dao->getMany($this); } /** * Filter by contexts */ public function filterByContextIds(?array $contextIds): self { $this->contextIds = $contextIds; return $this; } /** * Filter by submissions */ public function filterBySubmissionIds(?array $submissionIds): self { $this->submissionIds = $submissionIds; return $this; } public function filterByDoiIds(?array $doiIds): self { $this->doiIds = $doiIds; return $this; } /** * Limit the number of objects retrieved */ public function limit(?int $count): self { $this->count = $count; return $this; } /** * Offset the number of objects retrieved, for example to * retrieve the second page of contents */ public function offset(?int $offset): self { $this->offset = $offset; return $this; } /** * @copydoc CollectorInterface::getQueryBuilder() */ public function getQueryBuilder(): Builder { $qb = DB::table('publications as p') ->select(['p.*']); if (isset($this->contextIds)) { $qb->join('submissions as s', 'p.submission_id', '=', 's.submission_id'); $qb->whereIn('s.context_id', $this->contextIds); } if (isset($this->submissionIds)) { $qb->whereIn('p.submission_id', $this->submissionIds); } $qb->when($this->doiIds !== null, function (Builder $qb) { $qb->whereIn('p.doi_id', $this->doiIds); }); if (isset($this->count)) { $qb->limit($this->count); } if (isset($this->offset)) { $qb->offset($this->offset); } $qb->orderBy('p.version', 'asc'); // Add app-specific query statements Hook::call('Publication::Collector', [&$qb, $this]); return $qb; } }