aboutsummaryrefslogtreecommitdiff
path: root/lib/task/isisImportTask.class.php
blob: b6d70af14695c0252d4126c0a28871e44ce40981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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']);
  }
}