[ Index ]
 

Code source de Symfony 1.0.0

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

title

Body

[fermer]

/data/tasks/ -> sfPakePropelAdminGenerator.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('initialize a new propel admin module');
  12  pake_task('propel-init-admin', 'app_exists');
  13  
  14  function run_propel_init_admin($task, $args)
  15  {
  16    if (count($args) < 2)
  17    {
  18      throw new Exception('You must provide your module name.');
  19    }
  20  
  21    if (count($args) < 3)
  22    {
  23      throw new Exception('You must provide your model class name.');
  24    }
  25  
  26    $app         = $args[0];
  27    $module      = $args[1];
  28    $model_class = $args[2];
  29    $theme       = isset($args[3]) ? $args[3] : 'default';
  30  
  31    try
  32    {
  33      $author_name = $task->get_property('author', 'symfony');
  34    }
  35    catch (pakeException $e)
  36    {
  37      $author_name = 'Your name here';
  38    }
  39  
  40    $constants = array(
  41      'PROJECT_NAME' => $task->get_property('name', 'symfony'),
  42      'APP_NAME'     => $app,
  43      'MODULE_NAME'  => $module,
  44      'MODEL_CLASS'  => $model_class,
  45      'AUTHOR_NAME'  => $author_name,
  46      'THEME'        => $theme, 
  47    );
  48  
  49    $moduleDir = sfConfig::get('sf_root_dir').'/'.sfConfig::get('sf_apps_dir_name').'/'.$app.'/'.sfConfig::get('sf_app_module_dir_name').'/'.$module;
  50  
  51    // create module structure
  52    $finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf');
  53    $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $theme);
  54    foreach ($dirs as $dir)
  55    {
  56      if (is_dir($dir))
  57      {
  58        pake_mirror($finder, $dir, $moduleDir);
  59        break;
  60      }
  61    }
  62  
  63    // customize php and yml files
  64    $finder = pakeFinder::type('file')->name('*.php', '*.yml');
  65    pake_replace_tokens($finder, $moduleDir, '##', '##', $constants);
  66  }


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