Ejemplo n.º 1
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $version = sfSympalConfig::getCurrentVersion();
     $formattedVersion = $this->formatter->format($version, 'INFO');
     $dir = $this->configuration->getPluginConfiguration('sfSympalPlugin')->getRootDir();
     if (isset($options['check']) && $options['check']) {
         $upgrade = new sfSympalUpgradeFromWeb($this->configuration, $this->dispatcher, $this->formatter);
         if ($upgrade->hasNewVersion()) {
             $formattedVersion = $this->formatter->format($upgrade->getLatestVersion(), 'INFO');
             $this->log(sprintf("\nSympal %s is available for download.\n", $formattedVersion));
             $command = $this->formatter->format('./symfony sympal:upgrade --download-new', 'COMMENT');
             $this->log(sprintf("Run %s to download the new version and upgrade.\n", $command));
         } else {
             $this->log(sprintf("\nYou are up to date with Sympal %s (%s)\n", $formattedVersion, $dir));
         }
     } else {
         $this->log(sprintf('Current Sympal version %s (%s)', $formattedVersion, $dir));
     }
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     if (isset($options['download-new']) && $options['download-new']) {
         $upgrade = new sfSympalUpgradeFromWeb($this->configuration, $this->dispatcher, $this->formatter);
         if ($upgrade->hasNewVersion()) {
             if (!$options['no-confirmation'] && !$this->askConfirmation(array_merge(array(sprintf('A new version of Sympal was detected! Would you like to download and upgrade to %s?', $upgrade->getLatestVersion()), ''), array('Are you sure you want to proceed? (y/N)')), 'QUESTION_LARGE', false)) {
                 $this->logSection('sympal', 'task aborted');
                 return 1;
             }
             $upgrade->download();
         } else {
             throw new sfException('No new version of Sympal was found!');
         }
     } else {
         $upgrade = new sfSympalProjectUpgrade($this->configuration, $this->dispatcher, $this->formatter);
     }
     $this->logSection('sympal', 'Checking for upgrade tasks to execute...');
     if ($upgrade->hasUpgrades()) {
         $upgrades = $upgrade->getUpgrades();
         $numUpgrades = count($upgrades);
         $textUpgrades = array();
         foreach ($upgrades as $u) {
             $textUpgrades[] = $u['version'] . ' upgrade #' . $u['number'];
         }
         if (!$options['no-confirmation'] && !$this->askConfirmation(array_merge(array($numUpgrades . ' upgrade ' . ($numUpgrades > 1 ? 'tasks' : 'task') . ' found! The following upgrades will be executed:', ''), array_map(create_function('$v', 'return \' - \'.$v;'), $textUpgrades), array('', 'Are you sure you want to proceed? (y/N)')), 'QUESTION_LARGE', false)) {
             $this->logSection('doctrine', 'task aborted');
             return 1;
         }
         $upgrade->upgrade();
         $this->logSection('sympal', 'Successfully executed upgrade tasks');
         $this->logSection('sympal', 'You have successfully upgraded Sympal');
     } else {
         if (isset($options['download-new']) && $options['download-new']) {
             $this->logSection('sympal', 'No upgrade tasks required for upgrade');
         } else {
             throw new sfException('Nothing to upgrade.');
         }
     }
 }