public function getOrNew($id = null)
    {
        try {
            $model = $this->get($id);
        } catch (MappingException $e) {
            $modelClass = $this->getModelClass();
            $model      = new $modelClass();
        }

        return $model;
    }
public function getOrNew($id = null)
    {
        try {
            $model = $this->get($id);
        } catch (MappingException $e) {
            $modelClass = $this->getModelClass();
            $model      = new $modelClass();
        }

        return $model;
    }
public function getOrNew ( $ id = null ) { try { $ model = $ this -> get ( $ id ) ; } catch ( MappingException $ e ) { $ modelClass = $ this -> getModelClass ( ) ; $ model = new $ modelClass ( ) ; } return $ model ; }
Return the entity with the ID in the parameter. If it does not exist a new instance is returned.

@param int|string $id

@return Model
Return the entity with the ID in the parameter . If it does not exist a new instance is returned .