lib/components/types/Relationship.php
public function getPrimaryChild($parentObject)
    {
        if (!$this->handlePrimary) {
            return false;
        }
        if (!$this->child->getPrimaryAsChild($this->parent)) {
            return false;
        }
        $key = json_encode([__FUNCTION__, $this->systemId, $parentObject->primaryKey]);
        if (!isset(self::$_cache[$key])) {
            self::$_cache[$key] = null;
            $relationClass = Yii::$app->classes['Relation'];
            $childClass = $this->child->primaryModel;
            $relation = $relationClass::find();
            $alias = $relationClass::tableName();
            $relation->andWhere(['`' . $alias . '`.`parent_object_id`' => $parentObject->primaryKey, '`' . $alias . '`.`primary_child`' => 1]);
            $relation->andWhere(['or', '`' . $alias . '`.`child_object_id` LIKE :prefix']); //, '`'. $alias.'`.`child_object_id` LIKE \''.$childClass.'\''
            $relation->params[':prefix'] = $childClass::modelPrefix() . '-%';
            $parentObject->addActiveConditions($relation, $alias);
            $relation = $relation->one();
            if (!empty($relation)) {
                self::$_cache[$key] = $relation;
            }
        }

        return self::$_cache[$key];
    }
public function getPrimaryChild($parentObject)
    {
        if (!$this->handlePrimary) {
            return false;
        }
        if (!$this->child->getPrimaryAsChild($this->parent)) {
            return false;
        }
        $key = json_encode([__FUNCTION__, $this->systemId, $parentObject->primaryKey]);
        if (!isset(self::$_cache[$key])) {
            self::$_cache[$key] = null;
            $relationClass = Yii::$app->classes['Relation'];
            $childClass = $this->child->primaryModel;
            $relation = $relationClass::find();
            $alias = $relationClass::tableName();
            $relation->andWhere(['`' . $alias . '`.`parent_object_id`' => $parentObject->primaryKey, '`' . $alias . '`.`primary_child`' => 1]);
            $relation->andWhere(['or', '`' . $alias . '`.`child_object_id` LIKE :prefix']); //, '`'. $alias.'`.`child_object_id` LIKE \''.$childClass.'\''
            $relation->params[':prefix'] = $childClass::modelPrefix() . '-%';
            $parentObject->addActiveConditions($relation, $alias);
            $relation = $relation->one();
            if (!empty($relation)) {
                self::$_cache[$key] = $relation;
            }
        }

        return self::$_cache[$key];
    }
Get primary child.

@param [[@doctodo param_type:parentObject]] $parentObject [[@doctodo param_description:parentObject]]

@return [[@doctodo return_type:getPrimaryChild]] [[@doctodo return_description:getPrimaryChild]]