sfConfigurationUpgrade.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 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. * Upgrades the project configuration class for backward compatibility.
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfConfigurationUpgrade.class.php 13493 2008-11-29 15:36:41Z fabien $
  16. */
  17. class sfConfigurationUpgrade extends sfUpgrade
  18. {
  19. public function upgrade()
  20. {
  21. $file = sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php';
  22. $content = file_get_contents($file);
  23. if (!preg_match('/(enablePlugins|disablePlugins|enableAllPluginsExcept)/', $content))
  24. {
  25. $content = preg_replace("#(setup\(\)\s+{\s+)#s", "$1 \$this->enableAllPluginsExcept(array('sfDoctrinePlugin', 'sfCompat10Plugin'));\n ", $content, -1, $count);
  26. if ($count)
  27. {
  28. $this->logSection('config', sprintf('Migrating %s', $file));
  29. file_put_contents($file, $content);
  30. }
  31. }
  32. // update embedded symfony CLI
  33. $file = sfConfig::get('sf_root_dir').'/symfony';
  34. $content = file_get_contents($file);
  35. if (preg_match('/ProjectConfiguration/', $content))
  36. {
  37. $content = str_replace("\$configuration = new ProjectConfiguration();\n", '', $content);
  38. $content = str_replace("\$configuration->getSymfonyLibDir()", 'sfCoreAutoload::getInstance()->getBaseDir()', $content);
  39. $this->logSection('config', sprintf('Migrating %s', $file));
  40. file_put_contents($file, $content);
  41. }
  42. }
  43. }