/** * @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.'); } } }
/** * Runs the upgrade and then writes the latest version to config */ protected function _doUpgrade() { parent::_doUpgrade(); sfSympalConfig::writeSetting('current_version', $this->getLatestVersion()); }
public function __construct(ProjectConfiguration $configuration, sfEventDispatcher $dispatcher, sfFormatter $formatter) { parent::__construct($configuration, $dispatcher, $formatter); $this->_filesystem = new sfFilesystem($dispatcher, $formatter); $this->_currentVersion = sfSympalConfig::getCurrentVersion(); }