Esempio n. 1
0
 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = array();
     $command[] = !empty($this->bin) ? $this->bin : 'drush';
     if (!empty($this->alias)) {
         $command[] = $this->alias;
     }
     if (empty($this->color)) {
         $option = new DrushOption();
         $option->setName('nocolor');
         $this->options[] = $option;
     }
     if (!empty($this->root)) {
         $option = new DrushOption();
         $option->setName('root');
         $option->addText($this->root);
         $this->options[] = $option;
     }
     if (!empty($this->uri)) {
         $option = new DrushOption();
         $option->setName('uri');
         $option->addText($this->uri);
         $this->options[] = $option;
     }
     if (!empty($this->config)) {
         $option = new DrushOption();
         $option->setName('config');
         $option->addText($this->config);
         $this->options[] = $option;
     }
     if (!empty($this->aliasPath)) {
         $option = new DrushOption();
         $option->setName('alias-path');
         $option->addText($this->uri);
         $this->options[] = $option;
     }
     if (is_bool($this->assume)) {
         $option = new DrushOption();
         $option->setName($this->assume ? 'yes' : 'no');
         $this->options[] = $option;
     }
     if ($this->simulate) {
         $option = new DrushOption();
         $option->setName('simulate');
         $this->options[] = $option;
     }
     if ($this->pipe) {
         $option = new DrushOption();
         $option->setName('pipe');
         $this->options[] = $option;
     }
     if ($this->verbose) {
         $option = new DrushOption();
         $option->setName('verbose');
         $this->options[] = $option;
     }
     foreach ($this->options as $option) {
         $command[] = $option->toString();
     }
     $command[] = $this->command;
     foreach ($this->params as $param) {
         $command[] = '"' . escapeshellcmd($param->getValue()) . '"';
     }
     $command = implode(' ', $command);
     if ($this->dir !== NULL) {
         $currdir = getcwd();
         @chdir($this->dir->getPath());
     }
     // Execute Drush.
     $this->log("Executing '{$command}'...");
     $output = array();
     exec($command, $output, $return);
     if (isset($currdir)) {
         @chdir($currdir);
     }
     // Collect Drush output for display through Phing's log.
     foreach ($output as $line) {
         $this->log($line);
     }
     // Set value of the 'pipe' property.
     if (!empty($this->returnProperty)) {
         $this->getProject()->setProperty($this->returnProperty, implode($this->returnGlue, $output));
     }
     // Build fail.
     if ($this->haltOnError && $return != 0) {
         throw new BuildException("Drush exited with code {$return}");
     }
     return $return != 0;
 }
Esempio n. 2
0
 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = array();
     $command[] = !empty($this->bin) ? $this->bin : 'drush';
     $option = new DrushOption();
     $option->setName('nocolor');
     $this->options[] = $option;
     if (!empty($this->root)) {
         $option = new DrushOption();
         $option->setName('root');
         $option->addText($this->root);
         $this->options[] = $option;
     }
     if (!empty($this->uri)) {
         $option = new DrushOption();
         $option->setName('uri');
         $option->addText($this->uri);
         $this->options[] = $option;
     }
     if (is_bool($this->assume)) {
         $option = new DrushOption();
         $option->setName($this->assume ? 'yes' : 'no');
         $this->options[] = $option;
     }
     if ($this->simulate) {
         $option = new DrushOption();
         $option->setName('simulate');
         $this->options[] = $option;
     }
     if ($this->pipe) {
         $option = new DrushOption();
         $option->setName('pipe');
         $this->options[] = $option;
     }
     if ($this->verbose) {
         $option = new DrushOption();
         $option->setName('verbose');
         $this->options[] = $option;
     }
     foreach ($this->options as $option) {
         $command[] = $option->toString();
     }
     $command[] = $this->command;
     foreach ($this->params as $param) {
         $command[] = $param->getValue();
     }
     $command = implode(' ', $command);
     // Execute Drush.
     $this->log("Executing '{$command}'...");
     $output = array();
     exec($command, $output, $return);
     // Collect Drush output for display through Phing's log.
     foreach ($output as $line) {
         $this->log($line);
     }
     // Set value of the 'pipe' property.
     if (!empty($this->return_property)) {
         $this->getProject()->setProperty($this->return_property, implode($this->return_glue, $output));
     }
     // Build fail.
     if ($this->haltonerror && $return != 0) {
         throw new BuildException("Drush exited with code {$return}");
     }
     return $return != 0;
 }