[289] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of the sfPropel13Plugin package. |
---|
| 4 | * (c) 2007 Joshua May <notjosh@gmail.com> |
---|
| 5 | * |
---|
| 6 | * For the full copyright and license information, please view the LICENSE |
---|
| 7 | * file that was distributed with this source code. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * @package symfony.plugins |
---|
| 12 | * @subpackage sfPropel13Plugin |
---|
| 13 | * @author Joshua May <notjosh@gmail.com> |
---|
| 14 | * @version SVN: $Id$ |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | pake_desc('initialize a new propel admin module'); |
---|
| 18 | pake_task('propel-13-init-admin', 'app_exists'); |
---|
| 19 | |
---|
| 20 | function run_propel_13_init_admin($task, $args) |
---|
| 21 | { |
---|
| 22 | // run_propel_init_admin($task, $args); |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | if (count($args) < 2) |
---|
| 28 | { |
---|
| 29 | throw new Exception('You must provide your module name.'); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | if (count($args) < 3) |
---|
| 33 | { |
---|
| 34 | throw new Exception('You must provide your model class name.'); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | $app = $args[0]; |
---|
| 38 | $module = $args[1]; |
---|
| 39 | $model_class = $args[2]; |
---|
| 40 | $theme = isset($args[3]) ? $args[3] : 'default'; |
---|
| 41 | |
---|
| 42 | try |
---|
| 43 | { |
---|
| 44 | $author_name = $task->get_property('author', 'symfony'); |
---|
| 45 | } |
---|
| 46 | catch (pakeException $e) |
---|
| 47 | { |
---|
| 48 | $author_name = 'Your name here'; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | $constants = array( |
---|
| 52 | 'PROJECT_NAME' => $task->get_property('name', 'symfony'), |
---|
| 53 | 'APP_NAME' => $app, |
---|
| 54 | 'MODULE_NAME' => $module, |
---|
| 55 | 'MODEL_CLASS' => $model_class, |
---|
| 56 | 'AUTHOR_NAME' => $author_name, |
---|
| 57 | 'THEME' => $theme, |
---|
| 58 | ); |
---|
| 59 | |
---|
| 60 | $moduleDir = sfConfig::get('sf_root_dir').'/'.sfConfig::get('sf_apps_dir_name').'/'.$app.'/'.sfConfig::get('sf_app_module_dir_name').'/'.$module; |
---|
| 61 | |
---|
| 62 | // create module structure |
---|
| 63 | $finder = pakeFinder::type('any')->ignore_version_control()->discard('.sf'); |
---|
| 64 | $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $theme); |
---|
| 65 | foreach ($dirs as $dir) |
---|
| 66 | { |
---|
| 67 | if (is_dir($dir)) |
---|
| 68 | { |
---|
| 69 | pake_mirror($finder, $dir, $moduleDir); |
---|
| 70 | break; |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | // customize php and yml files |
---|
| 75 | $finder = pakeFinder::type('file')->name('*.php', '*.yml'); |
---|
| 76 | pake_replace_tokens($finder, $moduleDir, '##', '##', $constants); |
---|
| 77 | } |
---|