From 662d10abaa494324841a00fe09d494718684e03e Mon Sep 17 00:00:00 2001 From: Silvio Date: Fri, 30 Jul 2010 15:30:55 -0300 Subject: Fixing newModel behavior --- lib/sfIsisImporter.class.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/sfIsisImporter.class.php b/lib/sfIsisImporter.class.php index 6755477..4fd6353 100644 --- a/lib/sfIsisImporter.class.php +++ b/lib/sfIsisImporter.class.php @@ -123,24 +123,32 @@ class sfIsisImporter extends IsisConnector } /** - * Create a new model just if doesn't exist for a given entry. + * Create a new model just if doesn't exist for a given entry. For that + * to work the entry must provide and id. * * @param string $base_model Model to use * @param int $entry Entry number - * @return mixed New model with assigned id or false + * @return mixed New model or false */ public function newModel($base_model, $entry) { $model = new $base_model(); $id = $this->getBaseModelId($model); - if ($id && !call_user_func(array($base_model, 'getById'), $id)) + if ($id) { - $this->setBaseModelId($model); - return $model; + if (!call_user_func(array($base_model, 'getById'), $id)) + { + $this->setBaseModelId($model); + return $model; + } + else + { + return false; + } } - return false; + return $model; } /** -- cgit v1.2.3