Development

/branches/1.3/lib/task/project/upgrade1.3/sfTasksUpgrade.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/task/project/upgrade1.3/sfTasksUpgrade.class.php

Revision 20941, 2.0 kB (checked in by Kris.Wallsmith, 5 years ago)

[1.3] added sfWidgetFormInputText and made sfWidgetFormInput abstract

  • 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  * Renames references to renamed task classes.
13  *
14  * @package    symfony
15  * @subpackage task
16  * @author     Kris Wallsmith <kris.wallsmith@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfTasksUpgrade extends sfUpgrade
20 {
21   public function upgrade()
22   {
23     $finder = sfFinder::type('file')->name('*.php');
24     foreach ($finder->in($this->getProjectLibDirectories('/task')) as $file)
25     {
26       $contents = file_get_contents($file);
27       $changed = false;
28
29       // renamed data task classes
30       if (preg_match_all('/\bnew\b\s+\bsf(Doctrine|Propel)(Load|Dump)DataTask\b/i', $contents, $matches, PREG_OFFSET_CAPTURE))
31       {
32         foreach ($matches[0] as $match)
33         {
34           list($search, $offset) = $match;
35           $replace = str_ireplace(array('LoadData', 'DumpData'), array('DataLoad', 'DataDump'), $search);
36
37           $contents = substr($contents, 0, $offset).$replace.substr($contents, $offset + strlen($search));
38         }
39
40         $changed = true;
41       }
42
43       // sfConfigureDatabaseTask was renamed to sf(Doctrine|Propel)ConfigureDatabaseTask
44       if (preg_match_all('/\bnew\b\s+\bsfConfigureDatabaseTask\b/i', $contents, $matches, PREG_OFFSET_CAPTURE))
45       {
46         $newTask = sprintf('sf%sConfigureDatabaseTask', ucfirst(sfConfig::get('sf_orm')));
47         foreach ($matches[0] as $match)
48         {
49           list($search, $offset) = $match;
50           $replace = str_ireplace('sfConfigureDatabaseTask', $newTask, $search);
51
52           $contents = substr($contents, 0, $offset).$replace.substr($contents, $offset + strlen($search));
53         }
54
55         $changed = true;
56       }
57
58       if ($changed)
59       {
60         $this->logSection('task', 'Migrating '.$file);
61         file_put_contents($file, $contents);
62       }
63     }
64   }
65 }
66
Note: See TracBrowser for help on using the browser.