Completed
Push — master ( 9d31a7...55703c )
by Fabio
09:26
created
bin/prado-cli.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -623,31 +623,31 @@  discard block
 block discarded – undo
623 623
  */
624 624
 class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction
625 625
 {
626
-    protected $action = 'generateAll';
627
-    protected $parameters = array('output');
628
-    protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix');
629
-    protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files.";
630
-    private $_soap = false;
631
-    private $_prefix = '';
632
-    private $_postfix = '';
633
-    private $_overwrite = false;
634
-
635
-    public function performAction($args) {
636
-        $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir();
637
-        $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false;
638
-        $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false;
639
-        $this->_prefix = count($args) > 5 ? $args[5] : '';
640
-        $this->_postfix = count($args) > 6 ? $args[6] : '';
641
-
642
-        if ($app_dir !== false) {
643
-            $config = $this->getActiveRecordConfig($app_dir);
644
-
645
-            $manager = TActiveRecordManager::getInstance();
646
-            $con = $manager->getDbConnection();
647
-            $con->Active = true;
648
-
649
-            switch($con->getDriverName())
650
-           	{
626
+	protected $action = 'generateAll';
627
+	protected $parameters = array('output');
628
+	protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix');
629
+	protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files.";
630
+	private $_soap = false;
631
+	private $_prefix = '';
632
+	private $_postfix = '';
633
+	private $_overwrite = false;
634
+
635
+	public function performAction($args) {
636
+		$app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir();
637
+		$this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false;
638
+		$this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false;
639
+		$this->_prefix = count($args) > 5 ? $args[5] : '';
640
+		$this->_postfix = count($args) > 6 ? $args[6] : '';
641
+
642
+		if ($app_dir !== false) {
643
+			$config = $this->getActiveRecordConfig($app_dir);
644
+
645
+			$manager = TActiveRecordManager::getInstance();
646
+			$con = $manager->getDbConnection();
647
+			$con->Active = true;
648
+
649
+			switch($con->getDriverName())
650
+		   	{
651 651
 				case 'mysqli':
652 652
 				case 'mysql':
653 653
 					$command = $con->createCommand("SHOW TABLES");
@@ -665,27 +665,27 @@  discard block
 block discarded – undo
665 665
 				default:
666 666
 					echo "\n    Sorry, generateAll is not implemented for ".$con->getDriverName()."\n";
667 667
 					
668
-           	}
669
-
670
-            $dataReader = $command->query();
671
-            $dataReader->bindColumn(1, $table);
672
-            $tables = array();
673
-            while ($dataReader->read() !== false) {
674
-                $tables[] = $table;
675
-            }
676
-            $con->Active = False;
677
-            foreach ($tables as $key => $table) {
678
-                $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix;
679
-                if ($config !== false && $output !== false) {
680
-                    $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite);
681
-                }
682
-            }
683
-        }
684
-        return true;
685
-    }
686
-
687
-    public function generate($l)
688
-    {
668
+		   	}
669
+
670
+			$dataReader = $command->query();
671
+			$dataReader->bindColumn(1, $table);
672
+			$tables = array();
673
+			while ($dataReader->read() !== false) {
674
+				$tables[] = $table;
675
+			}
676
+			$con->Active = False;
677
+			foreach ($tables as $key => $table) {
678
+				$output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix;
679
+				if ($config !== false && $output !== false) {
680
+					$this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite);
681
+				}
682
+			}
683
+		}
684
+		return true;
685
+	}
686
+
687
+	public function generate($l)
688
+	{
689 689
 		$input = explode(" ", trim($l));
690 690
 		if(count($input) > 2)
691 691
 		{
@@ -702,49 +702,49 @@  discard block
 block discarded – undo
702 702
 		{
703 703
 			echo "\n    Usage: generate table_name Application.pages.RecordClassName\n";
704 704
 		}
705
-    }
706
-
707
-    protected function getAppDir($dir=".") {
708
-        if (is_dir($dir))
709
-            return realpath($dir);
710
-        if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
711
-            return $app_dir;
712
-        echo '** Unable to find directory "' . $dir . "\".\n";
713
-        return false;
714
-    }
715
-
716
-    protected function getXmlFile($app_dir) {
717
-        if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
718
-            return $xml;
719
-        if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
720
-            return $xml;
721
-        echo '** Unable to find application.xml in ' . $app_dir . "\n";
722
-        return false;
723
-    }
724
-
725
-    protected function getActiveRecordConfig($app_dir) {
726
-        if (false === ($xml = $this->getXmlFile($app_dir)))
727
-            return false;
728
-        if (false !== ($app = $this->initializePradoApplication($app_dir))) {
729
-            Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
730
-            foreach ($app->getModules() as $module)
731
-                if ($module instanceof TActiveRecordConfig)
732
-                    return $module;
733
-            echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
734
-        }
735
-        return false;
736
-    }
737
-
738
-    protected function getOutputFile($app_dir, $namespace) {
739
-        if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
740
-            return $namespace;
741
-        $file = Prado::getPathOfNamespace($namespace, "");
742
-        if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) {
743
-            if (strpos($path, $app_dir) === 0)
744
-                return $file;
745
-        }
746
-        echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
747
-        return false;
748
-    }
705
+	}
706
+
707
+	protected function getAppDir($dir=".") {
708
+		if (is_dir($dir))
709
+			return realpath($dir);
710
+		if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
711
+			return $app_dir;
712
+		echo '** Unable to find directory "' . $dir . "\".\n";
713
+		return false;
714
+	}
715
+
716
+	protected function getXmlFile($app_dir) {
717
+		if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
718
+			return $xml;
719
+		if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
720
+			return $xml;
721
+		echo '** Unable to find application.xml in ' . $app_dir . "\n";
722
+		return false;
723
+	}
724
+
725
+	protected function getActiveRecordConfig($app_dir) {
726
+		if (false === ($xml = $this->getXmlFile($app_dir)))
727
+			return false;
728
+		if (false !== ($app = $this->initializePradoApplication($app_dir))) {
729
+			Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
730
+			foreach ($app->getModules() as $module)
731
+				if ($module instanceof TActiveRecordConfig)
732
+					return $module;
733
+			echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
734
+		}
735
+		return false;
736
+	}
737
+
738
+	protected function getOutputFile($app_dir, $namespace) {
739
+		if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
740
+			return $namespace;
741
+		$file = Prado::getPathOfNamespace($namespace, "");
742
+		if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) {
743
+			if (strpos($path, $app_dir) === 0)
744
+				return $file;
745
+		}
746
+		echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
747
+		return false;
748
+	}
749 749
 
750 750
 }
Please login to merge, or discard this patch.