addArgument('rows', sfCommandArgument::OPTIONAL, 'Number of rows to process for each task'); $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'), new sfCommandOption('database', 'd', sfCommandOption::PARAMETER_REQUIRED, 'Database', null), )); $this->namespace = 'isis'; $this->name = 'batch'; $this->briefDescription = 'Imports an ISIS database into the application, batch version'; $this->detailedDescription = <<configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); // Initialize an IsisConnector. $class = (class_exists('IsisImporterManager')) ? 'IsisImporterManager' : 'sfIsisImporterManager'; $isis = new $class($options['loglevel']); // Error handling. if ($isis == FALSE) { $this->logSection('isis', 'Error opening ISIS database.'); return FALSE; } $databases = $isis->databases($options['database']); foreach ($databases as $database) { $rows = (isset($arguments['rows'])) ? $argument['rows'] : 20; $max = 1000; // TODO for ($offset = 0; $offset <= $max; $offset = $offset + $rows) { $pid = pcntl_fork(); if ($pid == -1) { die('Could not fork'); } else if ($pid) { // We are the parent. // Protect against Zombie children. pcntl_wait($status); } else { // We are the child. // Mass ISIS import. $isis->massImport($this, 'task', $rows, $offset, $database); } } } } }