aboutsummaryrefslogtreecommitdiff
path: root/lib/sfIsisImporter.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sfIsisImporter.class.php')
-rw-r--r--lib/sfIsisImporter.class.php28
1 files changed, 25 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)
{