diff options
author | Silvio <s1lv10@uol.com.br> | 2010-08-31 18:22:58 -0300 |
---|---|---|
committer | Silvio <s1lv10@uol.com.br> | 2010-08-31 18:22:58 -0300 |
commit | 58c0c37b33fc4521065ad06b4222fde3e71468e2 (patch) | |
tree | aa8e3d090cbe0c19f641954e3d754fddc62ff4c1 /lib/sfIsisImporterEntities.class.php | |
parent | 81cd263f4598115cc90817300f69a869fa5e444a (diff) | |
download | sf_isis_importer_plugin-58c0c37b33fc4521065ad06b4222fde3e71468e2.tar.gz sf_isis_importer_plugin-58c0c37b33fc4521065ad06b4222fde3e71468e2.tar.bz2 |
Changes into relations api
Diffstat (limited to 'lib/sfIsisImporterEntities.class.php')
-rw-r--r-- | lib/sfIsisImporterEntities.class.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/sfIsisImporterEntities.class.php b/lib/sfIsisImporterEntities.class.php index 56c2883..cd66afd 100644 --- a/lib/sfIsisImporterEntities.class.php +++ b/lib/sfIsisImporterEntities.class.php @@ -126,25 +126,41 @@ class sfIsisImporterEntities extends IsisConnector { * * @param string $entity Entity name * @param string $name Name value + * @param string $key Value key * @return object Entity data */ - public function addEntity($entity, $name) + public function addEntity($entity, $name, $key = 'name') { $name = $this->entityName($name); - $data = $this->getEntity($entity, $name); + $data = $this->getEntity($entity, $name, $key); if (!$data) { $this->log("Adding new $entity $name."); - $data = new $entity(); - $data->name = $name; - $data->save(); + $data = $this->newEntity($entity, $name, $key); } return $data; } /** + * Add a new entity into the database. + * + * @param string $entity Entity name + * @param string $name Name value + * @param string $key Value key + * @return object Entity data + */ + public function newEntity($entity, $name, $key = 'name') + { + $data = new $entity(); + $data->{$key} = $name; + $data->save(); + + return $data; + } + + /** * Add an element into the database if needed, returning * the resulting object. * |