aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sfIsisImporter.class.php28
-rw-r--r--lib/sfIsisImporterManager.class.php1
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/sfIsisImporter.class.php b/lib/sfIsisImporter.class.php
index 4fd6353..45046db 100644
--- a/lib/sfIsisImporter.class.php
+++ b/lib/sfIsisImporter.class.php
@@ -244,16 +244,38 @@ class sfIsisImporter extends IsisConnector
}
/**
+ * Get an existing entity.
+ *
+ * @param string $entity Entity name
+ * @param string $value Value to search for
+ * @param string $by Field to search $value
+ * @return mixed Entity data or false
+ */
+ public function getEntity($entity, $value, $by = 'name')
+ {
+ $findby = 'findOneBy'. ucfirst($by);
+ $data = Doctrine_Core::getTable($entity)->{$findby}($value);
+
+ if (!$data)
+ {
+ return $data;
+ }
+
+ return false;
+ }
+
+ /**
* Add a new entity into the database if needed, returning
* the corresponding object.
*
- * @param string $name Genre name
- * @return Genre Genre data
+ * @param string $entity Entity name
+ * @param string $name Name value
+ * @return object Entity data
*/
public function addEntity($entity, $name)
{
$name = $this->entityName($name);
- $data = Doctrine_Core::getTable($entity)->findOneByName($name);
+ $data = $this->getEntity($entity, $name);
if (!$data)
{
diff --git a/lib/sfIsisImporterManager.class.php b/lib/sfIsisImporterManager.class.php
index 756de8c..24b483e 100644
--- a/lib/sfIsisImporterManager.class.php
+++ b/lib/sfIsisImporterManager.class.php
@@ -100,6 +100,7 @@ class sfIsisImporterManager extends IsisConnector
}
}
+ ksort($databases);
return $databases;
}