* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Deploys a project to another server. * * @package symfony * @subpackage task * @author Fabien Potencier * @version SVN: $Id: sfProjectDeployTask.class.php 33125 2011-10-08 21:02:31Z fabien $ */ class sfProjectDeployTask extends sfBaseTask { protected $outputBuffer = '', $errorBuffer = ''; /** * @see sfTask */ protected function configure() { $this->addArguments(array( new sfCommandArgument('server', sfCommandArgument::REQUIRED, 'The server name'), )); $this->addOptions(array( new sfCommandOption('go', null, sfCommandOption::PARAMETER_NONE, 'Do the deployment'), new sfCommandOption('rsync-dir', null, sfCommandOption::PARAMETER_REQUIRED, 'The directory where to look for rsync*.txt files', 'config'), new sfCommandOption('rsync-options', null, sfCommandOption::PARAMETER_OPTIONAL, 'To options to pass to the rsync executable', '-azC --force --delete --progress'), )); $this->namespace = 'project'; $this->name = 'deploy'; $this->briefDescription = 'Deploys a project to another server'; $this->detailedDescription = <<getFilesystem()->execute($command, $options['trace'] ? array($this, 'logOutput') : null, array($this, 'logErrors')); $this->clearBuffers(); } public function logOutput($output) { if (false !== $pos = strpos($output, "\n")) { $this->outputBuffer .= substr($output, 0, $pos); $this->log($this->outputBuffer); $this->outputBuffer = substr($output, $pos + 1); } else { $this->outputBuffer .= $output; } } public function logErrors($output) { if (false !== $pos = strpos($output, "\n")) { $this->errorBuffer .= substr($output, 0, $pos); $this->log($this->formatter->format($this->errorBuffer, 'ERROR')); $this->errorBuffer = substr($output, $pos + 1); } else { $this->errorBuffer .= $output; } } protected function clearBuffers() { if ($this->outputBuffer) { $this->log($this->outputBuffer); $this->outputBuffer = ''; } if ($this->errorBuffer) { $this->log($this->formatter->format($this->errorBuffer, 'ERROR')); $this->errorBuffer = ''; } } }