| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class sfPropel13Upgrade extends sfUpgrade |
|---|
| 21 |
{ |
|---|
| 22 |
public function upgrade() |
|---|
| 23 |
{ |
|---|
| 24 |
$file = sfConfig::get('sf_config_dir').'/propel.ini'; |
|---|
| 25 |
if(is_readable($file)) |
|---|
| 26 |
{ |
|---|
| 27 |
|
|---|
| 28 |
$content = file_get_contents($file); |
|---|
| 29 |
$content = str_replace('addon.propel.builder.', 'plugins.sfPropelPlugin.lib.propel.builder.', $content, $count); |
|---|
| 30 |
|
|---|
| 31 |
if ($count) |
|---|
| 32 |
{ |
|---|
| 33 |
$this->logSection('propel', sprintf('Migrating %s', $file)); |
|---|
| 34 |
file_put_contents($file, $content); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
if (false === strpos($content, 'nestedsetpeer')) |
|---|
| 39 |
{ |
|---|
| 40 |
$content .= <<<EOF |
|---|
| 41 |
propel.builder.nestedset.class = plugins.sfPropelPlugin.lib.builder.SfNestedSetBuilder |
|---|
| 42 |
propel.builder.nestedsetpeer.class = plugins.sfPropelPlugin.lib.builder.SfNestedSetPeerBuilder |
|---|
| 43 |
EOF; |
|---|
| 44 |
$this->logSection('propel', sprintf('Migrating %s', $file)); |
|---|
| 45 |
file_put_contents($file, $content); |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
$content = file_get_contents($file); |
|---|
| 50 |
if (false === strpos($content, 'propel.defaultDateFormat')) |
|---|
| 51 |
{ |
|---|
| 52 |
$content .= <<<EOF |
|---|
| 53 |
|
|---|
| 54 |
propel.defaultTimeStampFormat = Y-m-d H:i:s |
|---|
| 55 |
propel.defaultTimeFormat = H:i:s |
|---|
| 56 |
propel.defaultDateFormat = Y-m-d |
|---|
| 57 |
|
|---|
| 58 |
EOF; |
|---|
| 59 |
$this->logSection('propel', sprintf('Migrating %s', $file)); |
|---|
| 60 |
file_put_contents($file, $content); |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
$models = sfFinder::type('file')->name('*.php')->maxdepth(0)->in(sfConfig::get('sf_lib_dir').'/model'); |
|---|
| 65 |
foreach ($models as $model) |
|---|
| 66 |
{ |
|---|
| 67 |
if(is_readable($model)) |
|---|
| 68 |
{ |
|---|
| 69 |
$content = file_get_contents($model); |
|---|
| 70 |
$content = str_replace(array('public function save($con = null)', 'public function delete($con = null)', 'SQLException', '->begin();', '->rollback();', '->prepareStatement(', '->executeQuery();'), |
|---|
| 71 |
array('public function save(PropelPDO $con = null)', 'public function delete(PropelPDO $con = null)', 'PDOException', '->beginTransaction();', '->rollBack();', '->prepare(', '->execute();'), |
|---|
| 72 |
$content, $count); |
|---|
| 73 |
|
|---|
| 74 |
if ($count) |
|---|
| 75 |
{ |
|---|
| 76 |
$this->logSection('propel', sprintf('Migrating %s', $model)); |
|---|
| 77 |
file_put_contents($model, $content); |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
} |
|---|
| 82 |
} |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|