Prado\Data\ActiveRecord\Scaffold\TScaffoldBase::getRecordObject PHP Method

getRecordObject() protected method

Gets the current Active Record instance. Creates new instance if the primary key value is null otherwise the record is fetched from the db.
protected getRecordObject ( $pk = null ) : TActiveRecord
return Prado\Data\ActiveRecord\TActiveRecord record instance
    protected function getRecordObject($pk = null)
    {
        if ($this->_record === null) {
            if ($pk !== null) {
                $this->_record = $this->getRecordFinder()->findByPk($pk);
                if ($this->_record === null) {
                    throw new TConfigurationException('scaffold_invalid_record_pk', $this->getRecordClass(), $pk);
                }
            } else {
                $class = $this->getRecordClass();
                if ($class !== null) {
                    $this->_record = Prado::createComponent($class);
                } else {
                    throw new TConfigurationException('scaffold_invalid_record_class', $this->getRecordClass(), $this->getID());
                }
            }
        }
        return $this->_record;
    }