[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/data/tasks/ -> sfPakeSymfony.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the symfony package.
   5   * (c) 2004-2006 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  pake_desc('freeze symfony libraries');
  12  pake_task('freeze', 'project_exists');
  13  
  14  pake_desc('unfreeze symfony libraries');
  15  pake_task('unfreeze', 'project_exists');
  16  
  17  function run_freeze($task, $args)
  18  {
  19    // check that the symfony librairies are not already freeze for this project
  20    if (is_readable('lib/symfony'))
  21    {
  22      throw new Exception('You can only freeze when lib/symfony is empty.');
  23    }
  24  
  25    if (is_readable('data/symfony'))
  26    {
  27      throw new Exception('You can only freeze when data/symfony is empty.');
  28    }
  29  
  30    if (is_readable('web/sf'))
  31    {
  32      throw new Exception('You can only freeze when web/sf is empty.');
  33    }
  34  
  35    if (is_link('web/sf'))
  36    {
  37      pake_remove('web/sf', '');
  38    }
  39  
  40    $symfony_lib_dir  = sfConfig::get('sf_symfony_lib_dir');
  41    $symfony_data_dir = sfConfig::get('sf_symfony_data_dir');
  42  
  43    pake_echo_action('freeze', 'freezing lib found in "'.$symfony_lib_dir.'"');
  44    pake_echo_action('freeze', 'freezing data found in "'.$symfony_data_dir.'"');
  45  
  46    pake_mkdirs('lib'.DIRECTORY_SEPARATOR.'symfony');
  47    pake_mkdirs('data'.DIRECTORY_SEPARATOR.'symfony');
  48  
  49    $finder = pakeFinder::type('any')->ignore_version_control();
  50    pake_mirror($finder, $symfony_lib_dir, 'lib/symfony');
  51    pake_mirror($finder, $symfony_data_dir, 'data/symfony');
  52  
  53    pake_rename('data/symfony/web/sf', 'web/sf');
  54  
  55    // change symfony paths in config/config.php
  56    file_put_contents('config/config.php.bak', "$symfony_lib_dir#$symfony_data_dir");
  57    _change_symfony_dirs("dirname(__FILE__).'/../lib/symfony'", "dirname(__FILE__).'/../data/symfony'");
  58  
  59    // install the command line
  60    pake_copy($symfony_data_dir.'/bin/symfony.php', 'symfony.php');
  61  }
  62  
  63  function run_unfreeze($task, $args)
  64  {
  65    // remove lib/symfony and data/symfony directories
  66    if (!is_dir('lib/symfony'))
  67    {
  68      throw new Exception('You can unfreeze only if you froze the symfony libraries before.');
  69    }
  70  
  71    $dirs = explode('#', file_get_contents('config/config.php.bak'));
  72    _change_symfony_dirs('\''.$dirs[0].'\'', '\''.$dirs[1].'\'');
  73  
  74    $finder = pakeFinder::type('any');
  75    pake_remove($finder, 'lib/symfony');
  76    pake_remove('lib/symfony', '');
  77    pake_remove($finder, 'data/symfony');
  78    pake_remove('data/symfony', '');
  79    pake_remove('symfony.php', '');
  80    pake_remove($finder, 'web/sf');
  81    pake_remove('web/sf', '');
  82  }
  83  
  84  function _change_symfony_dirs($symfony_lib_dir, $symfony_data_dir)
  85  {
  86    $content = file_get_contents('config/config.php');
  87    $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content);
  88    $content = preg_replace("/^(\s*.sf_symfony_data_dir\s*=\s*).+?;/m", "$1$symfony_data_dir;", $content);
  89    file_put_contents('config/config.php', $content);
  90  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7