private function createChoices($type) { if ($type == self::PROJECT_SPECIFIC) { return [Link::PRESENT_PROJECT => Link::presentedToText(Link::PRESENT_PROJECT), Link::PRESENT_GROUP => Link::presentedToText(Link::PRESENT_GROUP), Link::PRESENT_AREA => Link::presentedToText(Link::PRESENT_AREA)]; } else { return [Link::PRESENT_ADMIN => Link::presentedToText(Link::PRESENT_ADMIN), Link::PRESENT_USER => Link::presentedToText(Link::PRESENT_USER)]; } }
public function listData(DataTable $dataTable, TranslatorInterface $translator) { $qb = QueryBuilder::select()->field('i.id', 'id')->field('i.name', 'name')->field('i.presentedTo', 'presentedTo')->field('i.listOrder', 'order')->from(LinksTables::LINK_TBL, 'i'); if (null === $this->project) { $where = QueryClause::clause('i.`projectId` IS NULL'); } else { $where = QueryClause::clause('i.`projectId` = :projectId', ':projectId', $this->project->getId()); } $qb->postprocess(function ($row) use($translator) { $row['presentedToText'] = $translator->trans(Link::presentedToText($row['presentedTo'])); return $row; }); $recordsTotal = QueryBuilder::copyWithoutFields($qb)->field('COUNT(id)', 'cnt')->where($dataTable->buildCountingCondition($where))->fetchCell($this->conn); $recordsFiltered = QueryBuilder::copyWithoutFields($qb)->field('COUNT(id)', 'cnt')->where($dataTable->buildFetchingCondition($where))->fetchCell($this->conn); $dataTable->processQuery($qb); return $dataTable->createAnswer($recordsTotal, $recordsFiltered, $qb->where($dataTable->buildFetchingCondition($where))->fetchAll($this->conn)); }