2 // vim: foldmethod=marker
4 * Ethna_Plugin_Generator_EntryPoint.php
6 * @author ICHII Takashi <ichii386@schweetheart.jp>
7 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
12 // {{{ Ethna_Plugin_Generator_EntryPoint
16 * @author ICHII Takashi <ichii386@schweetheart.jp>
20 class Ethna_Plugin_Generator_EntryPoint extends Ethna_Plugin_Generator
26 * @param string $skelton スケルトンファイル名
27 * @param int $gateway ゲートウェイ
28 * @return true|Ethna_Error true:成功 Ethna_Error:失敗
30 function &generate($action_name, $skelton = null, $gateway = GATEWAY_WWW)
37 $entity = sprintf("%s/%s.%s", $this->ctl->getDirectory('www'),
38 $action_name, $this->ctl->getExt('php'));
41 $entity = sprintf("%s/%s.%s", $this->ctl->getDirectory('bin'),
42 $action_name, $this->ctl->getExt('php'));
45 $ret =& Ethna::raiseError(
46 'add-entry-point accepts only GATEWAY_WWW or GATEWAY_CLI.');
51 if ($skelton === null) {
54 $skelton = 'skel.entry_www.php';
57 $skelton = 'skel.entry_cli.php';
61 if (file_exists($entity)) {
62 printf("file [%s] already exists -> skip\n", $entity);
68 $macro['project_id'] = $this->ctl->getAppId();
69 $macro['action_name'] = $action_name;
70 $macro['dir_app'] = $this->ctl->getDirectory('app');
73 $user_macro = $this->_getUserMacro();
74 $macro = array_merge($macro, $user_macro);
77 $ret = $this->_generateFile($skelton, $entity, $macro);
79 printf("action script(s) successfully created [%s]\n", $entity);
81 printf("[warning] file creation failed [%s]\n", $entity);
82 return $true; // XXX: error handling
86 if ($gateway === GATEWAY_CLI) {
88 //$ret = Ethna_Util::chmod($entity, 0777);