diff options
author | Silvio <silvio@devlet.com.br> | 2010-11-17 16:51:16 -0200 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-11-17 16:51:16 -0200 |
commit | b549a90ac492bca7c6915d66db5677f2b9016def (patch) | |
tree | 0f53dc0d1a62742a04ed4cf23d47b849f4d44816 | |
parent | d665bccaa9ea9af94342a4fa96be545dc1dcd571 (diff) | |
download | sf_isis_importer_plugin-b549a90ac492bca7c6915d66db5677f2b9016def.tar.gz sf_isis_importer_plugin-b549a90ac492bca7c6915d66db5677f2b9016def.tar.bz2 |
Offset support
-rw-r--r-- | lib/sfIsisImporterManager.class.php | 11 | ||||
-rw-r--r-- | lib/task/isisImportTask.class.php | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/sfIsisImporterManager.class.php b/lib/sfIsisImporterManager.class.php index 548587e..c08545a 100644 --- a/lib/sfIsisImporterManager.class.php +++ b/lib/sfIsisImporterManager.class.php @@ -130,7 +130,7 @@ class sfIsisImporterManager extends IsisConnector * @param string $section Caller section (whether an action or task) * @param int $entries Number of entries to import (defaults to all) */ - public function massImport($caller, $section, $entries = NULL) + public function massImport($caller, $section, $entries = NULL, $offset = 0) { // Additional logging settings. $this->logger->setCaller($caller); @@ -145,11 +145,12 @@ class sfIsisImporterManager extends IsisConnector { // Determine base model and max entries. $this->log('Starting mass import procedure for database schema "'. $database .'".', 'notice'); - $base_model = $importer->isis->format['import']['base_model']; - $this->entries = ($entries != NULL && $entries <= $importer->isis->entries) ? $entries : $importer->isis->entries; + $base_model = $importer->isis->format['import']['base_model']; + $this->max = ($entries != NULL && $entries + $offset <= $importer->isis->entries) ? $entries + $offset : $importer->isis->entries; - if ($base_model) { - for ($entry = 1; $entry <= $this->entries; $entry++) + if ($base_model) + { + for ($entry = $offset + 1; $entry <= $this->max; $entry++) { $importer->addEntry($base_model, $entry); $this->progress($entry); diff --git a/lib/task/isisImportTask.class.php b/lib/task/isisImportTask.class.php index 76abd4f..660c106 100644 --- a/lib/task/isisImportTask.class.php +++ b/lib/task/isisImportTask.class.php @@ -5,6 +5,7 @@ class isisImportTask extends mySfTask protected function configure() { $this->addArgument('rows', sfCommandArgument::OPTIONAL, 'Optional number of rows to process'); + $this->addArgument('offset', sfCommandArgument::OPTIONAL, 'Optional row offset to start from'); $this->addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), @@ -41,6 +42,6 @@ EOF; } // Mass ISIS import. - $isis->massImport($this, 'task', $arguments['rows']); + $isis->massImport($this, 'task', $arguments['rows'], $arguments['offset']); } } |