lib/components/db/fields/Relation.php
public function getValue($createOnEmpty = true)
    {
        if (is_null($this->_value)) {
            $models = $this->baseModel->collectModels();
            $relationTabularId = RelationModel::generateTabularId($this->field);
            $this->_value = false;
            $field = $this->field;
            $fieldParts = explode(':', $field);
            $primaryObject = $this->relationship->getRelatedObject($this->baseModel, $this->modelRole, $this->model);

            if (isset($models[$relationTabularId])) {
                $this->_value = $models[$relationTabularId];
            } elseif ($primaryObject) {
                $this->_value = $primaryObject;
            } elseif ($createOnEmpty) {
                $modelClass = $this->relationship->companionRoleType($this->modelRole)->primaryModel;
                $this->_value = new $modelClass();
                $this->_value->tabularId = $this->field;
                $this->_value->_moduleHandler = $this->field;
            }
            $this->_value->setParentModel($this->baseModel);
          //  exit;
        }

        return $this->_value;
    }
public function getValue($createOnEmpty = true)
    {
        if (is_null($this->_value)) {
            $models = $this->baseModel->collectModels();
            $relationTabularId = RelationModel::generateTabularId($this->field);
            $this->_value = false;
            $field = $this->field;
            $fieldParts = explode(':', $field);
            $primaryObject = $this->relationship->getRelatedObject($this->baseModel, $this->modelRole, $this->model);

            if (isset($models[$relationTabularId])) {
                $this->_value = $models[$relationTabularId];
            } elseif ($primaryObject) {
                $this->_value = $primaryObject;
            } elseif ($createOnEmpty) {
                $modelClass = $this->relationship->companionRoleType($this->modelRole)->primaryModel;
                $this->_value = new $modelClass();
                $this->_value->tabularId = $this->field;
                $this->_value->_moduleHandler = $this->field;
            }
            $this->_value->setParentModel($this->baseModel);
          //  exit;
        }

        return $this->_value;
    }
public function getValue ( $ createOnEmpty = true ) { if ( is_null ( $ this -> _value ) ) { $ models = $ this -> baseModel -> collectModels ( ) ; $ relationTabularId = RelationModel :: generateTabularId ( $ this -> field ) ; $ this -> _value = false ; $ field = $ this -> field ; $ fieldParts = explode ( ':' , $ field ) ; $ primaryObject = $ this -> relationship -> getRelatedObject ( $ this -> baseModel , $ this -> modelRole , $ this -> model ) ; if ( isset ( $ models [ $ relationTabularId ] ) ) { $ this -> _value = $ models [ $ relationTabularId ] ; } elseif ( $ primaryObject ) { $ this -> _value = $ primaryObject ; } elseif ( $ createOnEmpty ) { $ modelClass = $ this -> relationship -> companionRoleType ( $ this -> modelRole ) -> primaryModel ; $ this -> _value = new $ modelClass ( ) ; $ this -> _value -> tabularId = $ this -> field ; $ this -> _value -> _moduleHandler = $ this -> field ; } $ this -> _value -> setParentModel ( $ this -> baseModel ) ; //  exit; } return $ this -> _value ; }
Get value.

@param boolean $createOnEmpty [[@doctodo param_description:createOnEmpty]] [optional]

@return [[@doctodo return_type:getValue]] [[@doctodo return_description:getValue]]
Get value .