1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- class sfProjectUnfreezeTask extends sfBaseTask
- {
-
- protected function configure()
- {
- $this->aliases = array('unfreeze');
- $this->namespace = 'project';
- $this->name = 'unfreeze';
- $this->briefDescription = 'Unfreezes symfony libraries';
- $this->detailedDescription = <<<EOF
- The [project:unfreeze|INFO] task removes all the symfony core files from
- the current project:
- [./symfony project:unfreeze|INFO]
- The task also changes [config/config.php|COMMENT] to switch to the
- old symfony files used before the [project:freeze|COMMENT] command was used.
- EOF;
- }
-
- protected function execute($arguments = array(), $options = array())
- {
-
- if (!is_dir('lib/symfony'))
- {
- throw new sfCommandException('You can unfreeze only if you froze the symfony libraries before.');
- }
-
- $config = sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php';
- $content = file_get_contents($config);
- if (preg_match('/^# FROZEN_SF_LIB_DIR\: (.+?)$/m', $content, $match))
- {
- $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter);
- $publishAssets->setCommandApplication($this->commandApplication);
- $symfonyLibDir = $match[1];
- $content = str_replace("# FROZEN_SF_LIB_DIR: {$match[1]}\n\n", '', $content);
-
-
- $content = preg_replace('#^require_once.+?$#m', sprintf("require_once '%s/autoload/sfCoreAutoload.class.php';", str_replace('\\', '\\\\', $symfonyLibDir)), $content, 1);
- file_put_contents($config, $content);
-
- $publishAssets->run(array(), array('--symfony-lib-dir='.$symfonyLibDir));
-
- $finder = sfFinder::type('any');
- $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_lib_dir').'/symfony'));
- $this->getFilesystem()->remove(sfConfig::get('sf_lib_dir').'/symfony');
- $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_data_dir').'/symfony'));
- $this->getFilesystem()->remove(sfConfig::get('sf_data_dir').'/symfony');
- $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_web_dir').'/sf'));
- $this->getFilesystem()->remove(sfConfig::get('sf_web_dir').'/sf');
- }
- }
- }
|