diff options
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. * |