/** * Mount additional (not related to parent key) conditions, extended by child loaders * (HAS_MANY, BELONGS_TO). * * @param Selector $selector * @return Selector */ protected function mountConditions(Selector $selector) { //We only going to mount morph key as additional condition if (!empty($morphKey = $this->getKey(RecordEntity::MORPH_KEY))) { if ($this->isJoinable()) { $selector->onWhere($morphKey, $this->parent->schema[ORM::M_ROLE_NAME]); } else { $selector->where($morphKey, $this->parent->schema[ORM::M_ROLE_NAME]); } } return $selector; }
/** * {@inheritdoc} */ protected function createSelector() { //To prevent morph key being added as where $selector = new Selector($this->orm, $this->getClass()); return $selector->where($selector->getPrimaryAlias() . '.' . $this->definition[RecordEntity::OUTER_KEY], $this->parent->getField($this->definition[RecordEntity::INNER_KEY], false)); }
/** * {@inheritdoc} * * Pivot table columns will be included. */ protected function configureColumns(Selector $selector) { if (!$this->isLoadable()) { return; } $this->dataOffset = $selector->generateColumns($this->getAlias(), $this->dataColumns); $this->pivotOffset = $selector->generateColumns($this->getPivotAlias(), $this->pivotColumns); }