/**
  * Mount additional (not related to parent key) conditions, extended by child loaders
  * (HAS_MANY, BELONGS_TO).
  *
  * @param RecordSelector $selector
  * @return RecordSelector
  */
 protected function mountConditions(RecordSelector $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}
  *
  * Pivot table columns will be included.
  */
 protected function configureColumns(RecordSelector $selector)
 {
     if (!$this->isLoadable()) {
         return;
     }
     $this->dataOffset = $selector->generateColumns($this->getAlias(), $this->dataColumns);
     $this->pivotOffset = $selector->generateColumns($this->pivotAlias(), $this->pivotColumns);
 }
 /**
  * {@inheritdoc}
  */
 protected function createSelector()
 {
     //To prevent morph key being added as where
     $selector = new RecordSelector($this->orm, $this->getClass());
     return $selector->where($selector->primaryAlias() . '.' . $this->definition[RecordEntity::OUTER_KEY], $this->parent->getField($this->definition[RecordEntity::INNER_KEY], false));
 }