Source for file Action.php

Documentation is available at Action.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Action.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: ba97e5350722f4cd3976e4ef272dea7e0756c17a $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_Action
  13. /**
  14.  *  スケルトン生成クラス
  15.  *
  16.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  アクションのスケルトンを生成する
  23.      *
  24.      *  @access public
  25.      *  @param  string  $action_name    アクション名
  26.      *  @param  string  $skelton        スケルトンファイル名
  27.      *  @param  int     $gateway        ゲートウェイ
  28.      *  @return true|Ethna_Error       true:成功 Ethna_Error:失敗
  29.      */
  30.     function generate($action_name$skelton null$gateway GATEWAY_WWW)
  31.     {
  32.         $action_dir $this->ctl->getActiondir($gateway);
  33.         $action_class $this->ctl->getDefaultActionClass($action_name$gateway);
  34.         $action_form $this->ctl->getDefaultFormClass($action_name$gateway);
  35.         $action_path $this->ctl->getDefaultActionPath($action_name);
  36.  
  37.         // entity
  38.         $entity $action_dir $action_path;
  39.         Ethna_Util::mkdir(dirname($entity)0755);
  40.  
  41.         // skelton
  42.         if ($skelton === null{
  43.             switch ($gateway{
  44.             case GATEWAY_WWW:
  45.                 $skelton "skel.action.php";
  46.                 break;
  47.             case GATEWAY_CLI:
  48.                 $skelton "skel.action_cli.php";
  49.                 break;
  50.             case GATEWAY_XMLRPC:
  51.                 $skelton "skel.action_xmlrpc.php";
  52.                 break;
  53.             default:
  54.                 $err Ethna::raiseError('unknown gateway.');
  55.                 return $err;
  56.             }
  57.         }
  58.  
  59.         // macro
  60.         $macro array();
  61.         $macro['project_id'$this->ctl->getAppId();
  62.         $macro['action_name'$action_name;
  63.         $macro['action_class'$action_class;
  64.         $macro['action_form'$action_form;
  65.         $macro['action_path'$action_path;
  66.  
  67.         // user macro
  68.         $user_macro $this->_getUserMacro();
  69.         $macro array_merge($macro$user_macro);
  70.  
  71.  
  72.         // generate
  73.         if (file_exists($entity)) {
  74.             printf("file [%s] already exists -> skip\n"$entity);
  75.         else if ($this->_generateFile($skelton$entity$macro== false{
  76.             printf("[warning] file creation failed [%s]\n"$entity);
  77.         else {
  78.             printf("action script(s) successfully created [%s]\n"$entity);
  79.         }
  80.  
  81.         $true true;
  82.         return $true;
  83.     }
  84. }
  85. // }}}

Documentation generated on Fri, 11 Nov 2011 03:57:16 +0900 by phpDocumentor 1.4.3