Source for file EntryPoint.php

Documentation is available at EntryPoint.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  EntryPoint.php
  5.  *
  6.  *  @author     ICHII Takashi <ichii386@schweetheart.jp>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: 73795a7f6d908dab7b3a471fce38131207ee9a13 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_EntryPoint
  13. /**
  14.  *  スケルトン生成クラス
  15.  *
  16.  *  @author     ICHII Takashi <ichii386@schweetheart.jp>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  エントリポイントのスケルトンを生成する
  23.      *
  24.      *  @access public
  25.      *  @param  string  $skelton    スケルトンファイル名
  26.      *  @param  int     $gateway    ゲートウェイ
  27.      *  @return true|Ethna_Error   true:成功 Ethna_Error:失敗
  28.      */
  29.     function generate($action_name$skelton null$gateway GATEWAY_WWW)
  30.     {
  31.         $true true;
  32.  
  33.         // entity
  34.         switch ($gateway{
  35.         case GATEWAY_WWW:
  36.             $entity sprintf("%s/%s.%s"$this->ctl->getDirectory('www'),
  37.                               $action_name$this->ctl->getExt('php'));
  38.             break;
  39.         case GATEWAY_CLI:
  40.             $entity sprintf("%s/%s.%s"$this->ctl->getDirectory('bin'),
  41.                               $action_name$this->ctl->getExt('php'));
  42.             break;
  43.         default:
  44.             $ret Ethna::raiseError(
  45.                 'add-entry-point accepts only GATEWAY_WWW or GATEWAY_CLI.');
  46.             return $ret;
  47.         }
  48.  
  49.         // skelton
  50.         if ($skelton === null{
  51.             switch ($gateway{
  52.             case GATEWAY_WWW:
  53.                 $skelton 'skel.entry_www.php';
  54.                 break;
  55.             case GATEWAY_CLI:
  56.                 $skelton 'skel.entry_cli.php';
  57.                 break;
  58.             }
  59.         }
  60.         if (file_exists($entity)) {
  61.             printf("file [%s] already exists -> skip\n"$entity);
  62.             return $true;
  63.         }
  64.  
  65.         // macro
  66.         $macro array();
  67.         $macro['project_id'$this->ctl->getAppId();
  68.         $macro['action_name'$action_name;
  69.         $macro['dir_app'$this->ctl->getDirectory('app');
  70.  
  71.         // user macro
  72.         $user_macro $this->_getUserMacro();
  73.         $macro array_merge($macro$user_macro);
  74.  
  75.         // generate
  76.         $ret $this->_generateFile($skelton$entity$macro);
  77.         if ($ret{
  78.             printf("action script(s) successfully created [%s]\n"$entity);
  79.         else {
  80.             printf("[warning] file creation failed [%s]\n"$entity);
  81.             return $true// XXX: error handling
  82.         }
  83.  
  84.         // chmod
  85.         if ($gateway === GATEWAY_CLI{
  86.             // is needed?
  87.             //$ret = Ethna_Util::chmod($entity, 0777);
  88.         }
  89.             
  90.  
  91.         return $true;
  92.     }
  93. }
  94. // }}}

Documentation generated on Fri, 11 Nov 2011 03:58:01 +0900 by phpDocumentor 1.4.3