OSDN Git Service

- create ethna command idea branche
[ethna/ethna.git] / Idea_Plugin_Extlib / class / Plugin / Generator / AppManager.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_Plugin_Generator_AppManager.php
5  *
6  *  @author     Masaki Fujimoto <fujimoto@php.net>
7  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
8  *  @package    Ethna
9  *  @version    $Id$
10  */
11
12 // {{{ Ethna_Plugin_Generator_AppManager
13 /**
14  *  スケルトン生成クラス
15  *
16  *  @author     Masaki Fujimoto <fujimoto@php.net>
17  *  @access     public
18  *  @package    Ethna
19  */
20 class Ethna_Plugin_Generator_AppManager extends Ethna_Plugin_Generator
21 {
22     /**
23      *  アプリケーションマネージャのスケルトンを生成する
24      *
25      *  @access public
26      *  @param  string  $manager_name    アプリケーションマネージ名
27      *  @return bool    true:成功 false:失敗
28      */
29     function generate($manager_name)
30     {
31         $class_name = $this->ctl->getManagerClassName($manager_name);
32         $app_dir = $this->ctl->getDirectory('app');
33         $app_path = "${class_name}.php";
34
35         $macro = array();
36         $macro['project_id'] = $this->ctl->getAppId();
37         $macro['app_path'] = $app_path;
38         $macro['app_manager'] = $class_name;
39
40         $user_macro = $this->_getUserMacro();
41         $macro = array_merge($macro, $user_macro);
42
43         $path = "$app_dir/$app_path";
44         Ethna_Util::mkdir(dirname($path), 0755);
45         if (file_exists($path)) {
46             printf("file [%s] already exists -> skip\n", $path);
47         } else if ($this->_generateFile("skel.app_manager.php", $path, $macro) == false) {
48             printf("[warning] file creation failed [%s]\n", $path);
49         } else {
50             printf("app-manager script(s) successfully created [%s]\n", $path);
51         }
52     }
53 }
54 // }}}
55 ?>