aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-11-17 18:31:22 -0200
committerSilvio <silvio@devlet.com.br>2010-11-17 18:31:22 -0200
commitab16e715c988c0ac27c3872640796adb0e81848f (patch)
treed9f731fcf1904458127a76475c95deeb45a60ed5 /lib
parentced00d51e39f2924ba98451673ca69bcf5fb52ac (diff)
downloadsf_isis_importer_plugin-ab16e715c988c0ac27c3872640796adb0e81848f.tar.gz
sf_isis_importer_plugin-ab16e715c988c0ac27c3872640796adb0e81848f.tar.bz2
Adding isis:info task
Diffstat (limited to 'lib')
-rw-r--r--lib/sfIsisImporterManager.class.php34
-rw-r--r--lib/task/isisInfoTask.class.php41
2 files changed, 74 insertions, 1 deletions
diff --git a/lib/sfIsisImporterManager.class.php b/lib/sfIsisImporterManager.class.php
index c08545a..b7c4608 100644
--- a/lib/sfIsisImporterManager.class.php
+++ b/lib/sfIsisImporterManager.class.php
@@ -105,6 +105,38 @@ class sfIsisImporterManager extends IsisConnector
}
/**
+ * Show database information.
+ *
+ * @param mixed $databases Optional database names
+ */
+ public function info($caller, $section = 'info', $databases = null)
+ {
+ // Additional logging settings.
+ $this->logger->setCaller($caller);
+ $this->logger->setSection($section);
+
+ if ($databases == null)
+ {
+ $databases = $this->databases();
+ }
+ elseif (!is_array($databases))
+ {
+ $databases = array($databases);
+ }
+
+ foreach ($databases as $database)
+ {
+ // Open database.
+ $importer = $this->newImporter($database);
+
+ if ($importer)
+ {
+ $this->log("Database $database: ". $importer->isis->entries .' rows.');
+ }
+ }
+ }
+
+ /**
* After import procedure.
*/
public function afterImport() {
@@ -130,7 +162,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, $offset = 0)
+ public function massImport($caller, $section, $entries = null, $offset = 0)
{
// Additional logging settings.
$this->logger->setCaller($caller);
diff --git a/lib/task/isisInfoTask.class.php b/lib/task/isisInfoTask.class.php
new file mode 100644
index 0000000..da4836c
--- /dev/null
+++ b/lib/task/isisInfoTask.class.php
@@ -0,0 +1,41 @@
+<?php
+
+class isisInfoTask extends mySfTask
+{
+ protected function configure()
+ {
+ $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 = 'info';
+ $this->briefDescription = 'List information of ISIS databases';
+ $this->detailedDescription = <<<EOF
+The [isis:info|INFO] task lists information of ISIS databases.
+Call it with:
+
+ [php symfony isis:import|INFO]
+EOF;
+ }
+
+ protected function execute($arguments = array(), $options = array())
+ {
+ // 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;
+ }
+
+ // Database information.
+ $isis->info($this, 'task');
+ }
+}