Exemple #1
0
 /**
  * execute
  * @param array $args
  * @param array $options
  * @return mixed|void
  * @throws Exception
  */
 public function execute(array $args, array $options = array())
 {
     if (isset($args[0])) {
         #if gen multi command generator
         if (strtolower($args[0]) == "multi") {
             $this->multiCommands($args, $options);
         } else {
             # single command generator
             if (strstr($args[0], ':')) {
                 $ex = explode(":", $args[0]);
                 $this->setGenerateObject(Bim\Db\Generator\Code::buildHandler(ucfirst($ex[0])));
                 $methodName = ucfirst($ex[0]) . ucfirst($ex[1]);
             } else {
                 throw new \Bim\Exception\BimException("Improperly formatted command. Example: php bim gen iblock:add");
             }
             $method = "gen" . $methodName;
             if (method_exists($this, $method)) {
                 $this->{$method}($args, $options);
             } else {
                 throw new \Bim\Exception\BimException("Missing command, see help Example: php bim help gen");
             }
         }
     } else {
         $this->createOther($args, $options);
     }
 }
Exemple #2
0
 /**
  * genSiteDelete
  * @param array $args
  * @param array $options
  */
 public function genSiteDelete(array $args, array $options = array())
 {
     $dialog = new \ConsoleKit\Widgets\Dialog($this->console);
     $siteId = isset($options['id']) ? $options['id'] : false;
     if (!$siteId) {
         $do = true;
         while ($do) {
             $desk = "Put id Site - no default/required";
             $siteId = $dialog->ask($desk . PHP_EOL . $this->color('[SITE_ID]:', \ConsoleKit\Colors::YELLOW), '', false);
             $obSite = new \CSite();
             $dbSite = $obSite->GetList($by = "sort", $order = "desc", array('ID' => $siteId));
             if ($dbSite === false || !$dbSite->SelectedRowsCount()) {
                 $this->error('Site with id = "' . $siteId . '" not exist.');
             } else {
                 $do = false;
             }
         }
     }
     # get description options
     $desc = isset($options['d']) ? $options['d'] : "";
     $autoTag = "delete";
     $this->_save($this->generateObject->generateDeleteCode($siteId), $this->generateObject->generateAddCode($siteId), $desc, $autoTag);
 }