/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // remove lib/symfony and data/symfony directories if (!is_dir('lib/symfony')) { throw new sfCommandException('You can unfreeze only if you froze the symfony libraries before.'); } // change symfony path in ProjectConfiguration.class.php $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); // need to escape windows pathes "symfony\1.2" -> "symfony\\1.2" // because preg_replace would then use \1 as group identifier resulting in "symfony.2" $content = preg_replace('#^require_once.+?$#m', sprintf("require_once '%s/autoload/sfCoreAutoload.class.php';", str_replace('\\', '\\\\', $symfonyLibDir)), $content, 1); file_put_contents($config, $content); // re-publish assets $publishAssets->run(array(), array('--symfony-lib-dir=' . $symfonyLibDir)); // remove files $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'); } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // check that the symfony librairies are not already freeze for this project if (is_readable(sfConfig::get('sf_lib_dir') . '/symfony')) { throw new sfCommandException('You can only freeze when lib/symfony is empty.'); } if (is_readable(sfConfig::get('sf_data_dir') . '/symfony')) { throw new sfCommandException('You can only freeze when data/symfony is empty.'); } if (is_readable(sfConfig::get('sf_web_dir') . '/sf')) { throw new sfCommandException('You can only freeze when web/sf is empty.'); } if (is_link(sfConfig::get('sf_web_dir') . '/sf')) { $this->getFilesystem()->remove(sfConfig::get('sf_web_dir') . '/sf'); } $symfonyLibDir = sfConfig::get('sf_symfony_lib_dir'); $symfonyDataDir = $arguments['symfony_data_dir']; if (!is_readable($symfonyDataDir)) { throw new sfCommandException(sprintf('The symfony data dir does not seem to be located at "%s".', $symfonyDataDir)); } $this->logSection('freeze', sprintf('freezing lib found in "%s"', $symfonyLibDir)); $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfonyDataDir)); $this->getFilesystem()->mkdirs('lib' . DIRECTORY_SEPARATOR . 'symfony'); $this->getFilesystem()->mkdirs('data' . DIRECTORY_SEPARATOR . 'symfony'); $finder = sfFinder::type('any')->exec(array($this, 'excludeTests')); $this->getFilesystem()->mirror($symfonyLibDir, sfConfig::get('sf_lib_dir') . '/symfony', $finder); $this->getFilesystem()->mirror($symfonyDataDir, sfConfig::get('sf_data_dir') . '/symfony', $finder); $this->getFilesystem()->rename(sfConfig::get('sf_data_dir') . '/symfony/web/sf', sfConfig::get('sf_web_dir') . '/sf'); $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); // change symfony path in ProjectConfiguration.class.php $config = sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php'; $content = file_get_contents($config); $content = str_replace('<?php', "<?php\n\n# FROZEN_SF_LIB_DIR: {$symfonyLibDir}", $content); $content = preg_replace('#(\'|")' . preg_quote($symfonyLibDir, '#') . '#', "dirname(__FILE__).\$1/../lib/symfony", $content); file_put_contents($config, $content); // re-publish assets $publishAssets->run(array(), array('--symfony-lib-dir=' . sfConfig::get('sf_lib_dir') . '/symfony')); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (file_exists('symfony')) { throw new sfCommandException(sprintf('A project named "%s" already exists in this directory.', $arguments['name'])); } // create basic project structure $finder = sfFinder::type('any')->discard('.sf'); $this->getFilesystem()->mirror(dirname(__FILE__) . '/skeleton/project', sfConfig::get('sf_root_dir'), $finder); // update project name and directory $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini', 'databases.yml'); $this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); // update ProjectConfiguration class $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'))); // update vhost sample file $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/vhost.sample', '##', '##', array('PROJECT_NAME' => $arguments['name'], 'SYMFONY_WEB_DIR' => sfConfig::get('sf_web_dir'), 'SYMFONY_SF_DIR' => realpath(sfCoreAutoload::getInstance()->getBaseDir() . '../data/web/sf'))); // fix permission for common directories $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->run(); // publish assets for core plugins $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); $publishAssets->run(array(), array('--core-only')); }
public function upgrade() { $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); $publishAssets->run(array(), array('--core-only')); }