src/behaviors/PolymorphicRelation.php
public function getPolymorphicRelation()
    {
        if ($this->_cached !== null) {
            return $this->_cached;
        }
        $className = $this->owner->getAttribute($this->classAttribute);
        if ($className == "") {
            return null;
        }
        if (!class_exists($className)) {
            Yii::error("Underlying object class " . $className . " not found!");
            return null;
        }
        $tableName = $className::tableName();
        $object = $className::find()->where([$tableName . '.id' => $this->owner->getAttribute($this->pkAttribute)])->one();
        if ($object !== null && $this->validateUnderlyingObjectType($object)) {
            $this->_cached = $object;
            return $object;
        }
        return null;
    }
public function getPolymorphicRelation()
    {
        if ($this->_cached !== null) {
            return $this->_cached;
        }
        $className = $this->owner->getAttribute($this->classAttribute);
        if ($className == "") {
            return null;
        }
        if (!class_exists($className)) {
            Yii::error("Underlying object class " . $className . " not found!");
            return null;
        }
        $tableName = $className::tableName();
        $object = $className::find()->where([$tableName . '.id' => $this->owner->getAttribute($this->pkAttribute)])->one();
        if ($object !== null && $this->validateUnderlyingObjectType($object)) {
            $this->_cached = $object;
            return $object;
        }
        return null;
    }
public function getPolymorphicRelation ( ) { if ( $ this -> _cached !== null ) { return $ this -> _cached ; } $ className = $ this -> owner -> getAttribute ( $ this -> classAttribute ) ; if ( $ className == "" ) { return null ; } if ( ! class_exists ( $ className ) ) { Yii :: error ( "Underlying object class " . $ className . " not found!" ) ; return null ; } $ tableName = $ className :: tableName ( ) ; $ object = $ className :: find ( ) -> where ( [ $ tableName . '.id' => $ this -> owner -> getAttribute ( $ this -> pkAttribute ) ] ) -> one ( ) ; if ( $ object !== null && $ this -> validateUnderlyingObjectType ( $ object ) ) { $ this -> _cached = $ object ; return $ object ; } return null ; }
Returns the Underlying Object

@return mixed
Returns the Underlying Object