diff options
author | Silvio <s1lv10@uol.com.br> | 2010-07-30 17:58:44 -0300 |
---|---|---|
committer | Silvio <s1lv10@uol.com.br> | 2010-07-30 17:58:44 -0300 |
commit | 4eb178a51f91dec315ce3de7089bffd6bcbf8d22 (patch) | |
tree | 88e8f549a5295c3f40b4f1474cb7a439fbe99ac4 /lib/sfIsisImporter.class.php | |
parent | 662d10abaa494324841a00fe09d494718684e03e (diff) | |
download | sf_isis_importer_plugin-4eb178a51f91dec315ce3de7089bffd6bcbf8d22.tar.gz sf_isis_importer_plugin-4eb178a51f91dec315ce3de7089bffd6bcbf8d22.tar.bz2 |
Fixes around getEntity
Diffstat (limited to 'lib/sfIsisImporter.class.php')
-rw-r--r-- | lib/sfIsisImporter.class.php | 28 |
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) { |