| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfProjectUnfreezeTask extends sfBaseTask |
|---|
| 20 |
{ |
|---|
| 21 |
|
|---|
| 22 |
* @see sfTask |
|---|
| 23 |
*/ |
|---|
| 24 |
protected function configure() |
|---|
| 25 |
{ |
|---|
| 26 |
$this->aliases = array('unfreeze'); |
|---|
| 27 |
$this->namespace = 'project'; |
|---|
| 28 |
$this->name = 'unfreeze'; |
|---|
| 29 |
$this->briefDescription = 'Unfreezes symfony libraries'; |
|---|
| 30 |
|
|---|
| 31 |
$this->detailedDescription = <<<EOF |
|---|
| 32 |
The [project:unfreeze|INFO] task removes all the symfony core files from |
|---|
| 33 |
the current project: |
|---|
| 34 |
|
|---|
| 35 |
[./symfony project:unfreeze|INFO] |
|---|
| 36 |
|
|---|
| 37 |
The task also changes [config/config.php|COMMENT] to switch to the |
|---|
| 38 |
old symfony files used before the [project:freeze|COMMENT] command was used. |
|---|
| 39 |
EOF; |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
* @see sfTask |
|---|
| 44 |
*/ |
|---|
| 45 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 46 |
{ |
|---|
| 47 |
|
|---|
| 48 |
if (!is_dir('lib/symfony')) |
|---|
| 49 |
{ |
|---|
| 50 |
throw new sfCommandException('You can unfreeze only if you froze the symfony libraries before.'); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$config = sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php'; |
|---|
| 55 |
$content = file_get_contents($config); |
|---|
| 56 |
if (preg_match('/^# FROZEN_SF_LIB_DIR\: (.+?)$/m', $content, $match)) |
|---|
| 57 |
{ |
|---|
| 58 |
$content = str_replace("# FROZEN_SF_LIB_DIR: {$match[1]}\n\n", '', $content); |
|---|
| 59 |
|
|---|
| 60 |
// because preg_replace would then use \1 as group identifier resulting in "symfony.2" |
|---|
| 61 |
$content = preg_replace('#^require_once.+?$#m', sprintf("require_once '%s/autoload/sfCoreAutoload.class.php';", str_replace('\\', '\\\\', $match[1])), $content, 1); |
|---|
| 62 |
file_put_contents($config, $content); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
$finder = sfFinder::type('any'); |
|---|
| 66 |
$this->getFilesystem()->remove($finder->in(sfConfig::get('sf_lib_dir').'/symfony')); |
|---|
| 67 |
$this->getFilesystem()->remove(sfConfig::get('sf_lib_dir').'/symfony'); |
|---|
| 68 |
$this->getFilesystem()->remove($finder->in(sfConfig::get('sf_data_dir').'/symfony')); |
|---|
| 69 |
$this->getFilesystem()->remove(sfConfig::get('sf_data_dir').'/symfony'); |
|---|
| 70 |
$this->getFilesystem()->remove($finder->in(sfConfig::get('sf_web_dir').'/sf')); |
|---|
| 71 |
$this->getFilesystem()->remove(sfConfig::get('sf_web_dir').'/sf'); |
|---|
| 72 |
} |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|