From c7a3916e8215deedb95dd9e7aa314ac254120962 Mon Sep 17 00:00:00 2001 From: Silvio Date: Fri, 3 Sep 2010 18:13:41 -0300 Subject: newOrExisting with new $by parameter --- lib/sfIsisImporterEntities.class.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sfIsisImporterEntities.class.php b/lib/sfIsisImporterEntities.class.php index 73fe3af..a371462 100644 --- a/lib/sfIsisImporterEntities.class.php +++ b/lib/sfIsisImporterEntities.class.php @@ -175,7 +175,7 @@ class sfIsisImporterEntities { * @param string $value Entity value * @return object Entity data */ - public function newOrExisting($entity, $value) + public function newOrExisting($entity, $value, $by = 'Name') { // Check for a null value. if ($value == null) @@ -184,17 +184,15 @@ class sfIsisImporterEntities { return; } - // Get name. - $name = $this->parseName($value); - // Get existing element. - $element = call_user_func(array($entity, 'getByName'), $name); + $name = ($by == 'Name') ? $this->parseName($value) : $value; + $element = call_user_func(array($entity, 'getBy'. $by), $name); // Create new element if needed. if (!$element) { $this->log("Adding new $entity $value."); - $element = call_user_func(array($entity, 'addByName'), $name); + $element = call_user_func(array($entity, 'addBy'. $by), $name); } return $element; -- cgit v1.2.3