sfUpgradeTo12Task.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Upgrade a project to the 1.2 release (from 1.1).
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfUpgradeTo12Task.class.php 10628 2008-08-03 15:03:08Z fabien $
  16. */
  17. class sfUpgradeTo12Task extends sfBaseTask
  18. {
  19. /**
  20. * @see sfTask
  21. */
  22. protected function configure()
  23. {
  24. $this->namespace = 'project';
  25. $this->name = 'upgrade1.2';
  26. $this->briefDescription = 'Upgrade a symfony project to the 1.2 symfony release (from 1.1)';
  27. $this->detailedDescription = <<<EOF
  28. The [project:upgrade1.2|INFO] task upgrades a symfony project
  29. based on the 1.1 release to the 1.2 symfony release.
  30. [./symfony project:upgrade1.2|INFO]
  31. Please read the UPGRADE_TO_1_2 file to have information on what does this task.
  32. EOF;
  33. }
  34. /**
  35. * @see sfTask
  36. */
  37. protected function execute($arguments = array(), $options = array())
  38. {
  39. foreach ($this->getUpgradeClasses() as $class)
  40. {
  41. $upgrader = new $class($this->dispatcher, $this->formatter);
  42. $upgrader->setCommandApplication($this->commandApplication);
  43. $upgrader->upgrade();
  44. }
  45. }
  46. protected function getUpgradeClasses()
  47. {
  48. $baseDir = dirname(__FILE__).'/upgrade1.2/';
  49. $classes = array();
  50. foreach (glob($baseDir.'*.class.php') as $file)
  51. {
  52. $class = str_replace(array($baseDir, '.class.php'), '', $file);
  53. if ('sfUpgrade' != $class)
  54. {
  55. $classes[] = $class;
  56. require_once $baseDir.$class.'.class.php';
  57. }
  58. }
  59. return $classes;
  60. }
  61. }