diff options
author | Silvio <s1lv10@uol.com.br> | 2010-09-03 18:13:41 -0300 |
---|---|---|
committer | Silvio <s1lv10@uol.com.br> | 2010-09-03 18:13:41 -0300 |
commit | c7a3916e8215deedb95dd9e7aa314ac254120962 (patch) | |
tree | 038f78615f776a7fe0187f0e94e94d86f599ee35 /lib | |
parent | 97115d41a806a35a1b027114df725e68d45cb036 (diff) | |
download | sf_isis_importer_plugin-c7a3916e8215deedb95dd9e7aa314ac254120962.tar.gz sf_isis_importer_plugin-c7a3916e8215deedb95dd9e7aa314ac254120962.tar.bz2 |
newOrExisting with new $by parameter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sfIsisImporterEntities.class.php | 10 |
1 files changed, 4 insertions, 6 deletions
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; |