Example #1
0
 /**
  * Constructor method to instantiate the CLI object
  *
  * @param  array $args
  * @return self
  */
 public function __construct($args = array())
 {
     $this->args = $args;
     if (isset($this->args[1]) && $this->args[1] == 'help') {
         $this->help();
         exit;
     } else {
         if (isset($this->args[1]) && !in_array($this->args[1], $this->commands)) {
             echo '  The command \'' . $this->args[1] . '\' was not recognized. Use ./phire help for help.' . PHP_EOL . PHP_EOL;
             exit;
         }
     }
     if (isset($this->args[1]) && $this->args[1] != 'install' && !Project::isInstalled(true)) {
         echo '  Phire CMS 2 does not appear to be installed. Please check the config file or install the application.' . PHP_EOL . PHP_EOL;
         exit;
     } else {
         if (isset($this->args[1]) && $this->args[1] == 'install' && Project::isInstalled(true)) {
             echo '  Phire CMS 2 appears to already be installed.' . PHP_EOL . PHP_EOL;
             exit;
         } else {
             if (isset($this->args[1])) {
                 switch ($this->args[1]) {
                     case 'config':
                         $this->config();
                         break;
                     case 'version':
                         $this->version();
                         break;
                     case 'user':
                         $this->user();
                         break;
                     case 'ext':
                         $this->ext();
                         break;
                     case 'install':
                         $this->install();
                         break;
                     case 'update':
                         $this->update();
                         break;
                 }
             }
         }
     }
 }