Bootstrap
[ class tree: Bootstrap ] [ index: Bootstrap ] [ all elements ]

Source for file DoctrineCli.php

Documentation is available at DoctrineCli.php

  1. <?php
  2. /**
  3.  * Application_Bootstrap_DoctrineCli
  4.  * 
  5.  * Copyright (C) 2009  Mai (Me Artificial Intelligence)
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation, either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  * 
  20.  * @author Wouter Bulten (wouterbulten@mai-ai.org)
  21.  * @copyright Copyright (C) 2009  Mai (Me Artificial Intelligence)
  22.  * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  23.  * @link http://www.launchpad.net/mai
  24.  * 
  25.  * @package Bootstrap
  26.  * @subpackage DoctrineCli
  27.  * 
  28.  */
  29.  
  30. /**
  31.  * Application_Bootstrap_DoctrineCli is the bootstrap for the Doctrine CLI interface.
  32.  * 
  33.  * @author Wouter Bulten (wouterbulten@mai-ai.org)
  34.  * @copyright Copyright (C) 2009  Mai (Me Artificial Intelligence)
  35.  * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  36.  * @link http://www.launchpad.net/mai
  37.  * 
  38.  * @package Bootstrap
  39.  * @subpackage DoctrineCli
  40.  * 
  41.  *  
  42.  */
  43. {
  44.     /**
  45.      * Private constructor to prevent creation of this object.
  46.      * @return void 
  47.      */
  48.     private function __construct(){}
  49.     
  50.     /**
  51.      * Starts up the bootstrap.
  52.      * @param $arguments 
  53.      * @return void 
  54.      */
  55.     static public function run($arguments)
  56.     {
  57.         fwrite(STDOUT"\n" "Mai Doctrine Command Line Interface :: ");
  58.         
  59.         //Set include paths
  60.         parent::initIncludePaths();
  61.         //Start auto loader
  62.         parent::initAutoLoader();
  63.         //Load global config
  64.         parent::initGlobalConfig();
  65.         
  66.         //Create a connection (with base or user db)
  67.         if($key array_search('basedb'$arguments))
  68.         {
  69.             unset($arguments[$key])//Unset to prevent Doctrine error
  70.             rsort($arguments)//Sort the array
  71.     
  72.             fwrite(STDOUT"Working on base DB" "\n\n");
  73.         
  74.             //Start connection with base db
  75.             parent::initBaseDbConnection(parent::returnDbConfig());
  76.             
  77.             //Start CLI
  78.             self::initDoctrineCli(parent::returnDoctrineCliConfigBase());
  79.         }
  80.         else
  81.         {
  82.             fwrite(STDOUT"Working on user DB" "\n\n");
  83.             
  84.             //Start connection with user db
  85.             parent::initUserDbConnection(parent::returnDbConfig());
  86.             
  87.             //Start CLI
  88.             self::initDoctrineCli(parent::returnDoctrineCliConfigUser());
  89.         }    
  90.     }
  91.     
  92.     /**
  93.      * Start up CLI.
  94.      * @param array $config 
  95.      * @return void 
  96.      */
  97.     static private function initDoctrineCli(array $config)
  98.     {
  99.         //Start up CLI
  100.         $cli new Doctrine_Cli($config);
  101.         $cli->run($_SERVER['argv']);
  102.     }
  103. }

Documentation generated on Mon, 27 Jul 2009 19:51:56 +0200 by phpDocumentor 1.4.1