/** * {@inheritdoc} */ public function getSelectBuilder() { if (!$this->selectBuilder) { $this->selectBuilder = $this->collection->getMetadata()->getCollectionDataSource()->select(); $selectiveFields = $this->resolveSelectiveFields($this->collection, $this->fields, $this->types); $selectiveFields = array_merge($selectiveFields, $this->forcedFields); $columns = $this->getSelectedColumns($selectiveFields, $this->collection->getSourceAlias()); $columns = array_merge($columns, $this->getSelectedWithColumns()); $this->selectBuilder->setColumns($columns); $this->applyFrom($this->selectBuilder); $this->applyJoins($this->selectBuilder); $this->selectBuilder->where(IExpressionGroup::MODE_AND); $this->applyTypeConditions($this->selectBuilder); if ($this->fieldConditionsGroup) { $this->fieldConditionsGroup->applyConditions($this->selectBuilder); } $this->applyOrderConditions($this->selectBuilder); $this->applyLimitConditions($this->selectBuilder); if (is_callable($this->builderInitializer)) { $initializer = $this->builderInitializer; $initializer($this->selectBuilder); } } return $this->selectBuilder; }