diff options
author | Silvio <s1lv10@uol.com.br> | 2010-07-28 12:08:01 -0300 |
---|---|---|
committer | Silvio <s1lv10@uol.com.br> | 2010-07-28 12:08:01 -0300 |
commit | b68832a00307b23fc402b501166d5ecc89447785 (patch) | |
tree | f093ee490afe4a578532d10f62aa6cd3902017fc /lib/task/isisImportTask.class.php | |
download | sf_isis_importer_plugin-b68832a00307b23fc402b501166d5ecc89447785.tar.gz sf_isis_importer_plugin-b68832a00307b23fc402b501166d5ecc89447785.tar.bz2 |
Initial import
Diffstat (limited to 'lib/task/isisImportTask.class.php')
-rw-r--r-- | lib/task/isisImportTask.class.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/task/isisImportTask.class.php b/lib/task/isisImportTask.class.php new file mode 100644 index 0000000..b6d70af --- /dev/null +++ b/lib/task/isisImportTask.class.php @@ -0,0 +1,45 @@ +<?php + +class isisImportTask extends mySfTask +{ + protected function configure() + { + $this->addArgument('rows', sfCommandArgument::OPTIONAL, 'Optional number of rows to process'); + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + new sfCommandOption('loglevel', 'l', sfCommandOption::PARAMETER_REQUIRED, 'Log level', 'info'), + )); + + $this->namespace = 'isis'; + $this->name = 'import'; + $this->briefDescription = 'Imports an ISIS database into the application'; + $this->detailedDescription = <<<EOF +The [isis:import|INFO] task imports an ISIS database into the application. +Call it with: + + [php symfony isis:import|INFO] +EOF; + } + + protected function execute($arguments = array(), $options = array()) + { + // initialize the database connection + $databaseManager = new sfDatabaseManager($this->configuration); + $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); + + // Initialize an IsisConnector. + $isis = new CineImporter($options['loglevel']); + + // Error handling. + if ($isis == FALSE) + { + $this->logSection('isis', 'Error opening ISIS database.'); + return FALSE; + } + + // Mass ISIS import. + $isis->massImport($this, 'task', $arguments['rows']); + } +} |