Development

/branches/1.2/lib/task/project/upgrade1.2/sfConfigurationUpgrade.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/task/project/upgrade1.2/sfConfigurationUpgrade.class.php

Revision 13493, 1.6 kB (checked in by fabien, 6 years ago)

[1.2] added automatic migration for the generated symfony CLI

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * Upgrades the project configuration class for backward compatibility.
13  *
14  * @package    symfony
15  * @subpackage task
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfConfigurationUpgrade extends sfUpgrade
20 {
21   public function upgrade()
22   {
23     $file = sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php';
24     $content = file_get_contents($file);
25
26     if (!preg_match('/(enablePlugins|disablePlugins|enableAllPluginsExcept)/', $content))
27     {
28       $content = preg_replace("#(setup\(\)\s+{\s+)#s", "$1  \$this->enableAllPluginsExcept(array('sfDoctrinePlugin', 'sfCompat10Plugin'));\n  ", $content, -1, $count);
29       if ($count)
30       {
31         $this->logSection('config', sprintf('Migrating %s', $file));
32         file_put_contents($file, $content);
33       }
34     }
35
36     // update embedded symfony CLI
37     $file = sfConfig::get('sf_root_dir').'/symfony';
38     $content = file_get_contents($file);
39
40     if (preg_match('/ProjectConfiguration/', $content))
41     {
42       $content = str_replace("\$configuration = new ProjectConfiguration();\n", '', $content);
43       $content = str_replace("\$configuration->getSymfonyLibDir()", 'sfCoreAutoload::getInstance()->getBaseDir()', $content);
44       $this->logSection('config', sprintf('Migrating %s', $file));
45       file_put_contents($file, $content);
46     }
47   }
48 }
49
Note: See TracBrowser for help on using the browser.