Author: mcantelon
Date: Wed Aug 22 15:24:46 2012
New Revision: 12170
Log:
Added command-line option to CSV import for specifying a parent slug.
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Wed Aug 22 14:31:39
2012 (r12169)
+++ trunk/lib/task/import/csvImportTask.class.php Wed Aug 22 15:24:46
2012 (r12170)
@@ -43,7 +43,8 @@
parent::configure();
$this->addOptions(array(
- new sfCommandOption('source-name', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Source name to use when inserting keymap
entries.')
+ new sfCommandOption('source-name', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Source name to use when inserting keymap
entries.'),
+ new sfCommandOption('parent-slug', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Parent slug under which imported items
will be added.')
));
}
@@ -384,15 +385,24 @@
}
if (
- isset($self->rowStatusVars['qubitParentSlug'])
- && $self->rowStatusVars['qubitParentSlug']
+ (
+ isset($self->rowStatusVars['qubitParentSlug'])
+ && $self->rowStatusVars['qubitParentSlug']
+ )
+ || $self->status['options']['parent-slug']
)
{
+ // if a parent slug is specified by the command-line, that will
+ // override any parent slug specified in the current CSV row
+ $parentSlug = ($self->status['options']['parent-slug'])
+ ? $self->status['options']['parent-slug']
+ : $self->rowStatusVars['qubitParentSlug'];
+
$query = "SELECT object_id FROM slug WHERE slug=?";
$statement = QubitFlatfileImport::sqlQuery(
$query,
- array($self->rowStatusVars['qubitParentSlug'])
+ array($parentSlug)
);
$result = $statement->fetch(PDO::FETCH_OBJ);
@@ -401,7 +411,7 @@
{
$parentId = $result->object_id;
} else {
- throw new sfException('Could not find information object matching
slug "'. $self->rowStatusVars['qubitParentSlug'] .'"');
+ throw new sfException('Could not find information object matching
slug "'. $parentSlug .'"');
}
} else {
if (!isset($self->rowStatusVars['parentId']) ||
!$self->rowStatusVars['parentId'])
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.