Source for file AppObject.php

Documentation is available at AppObject.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  AppObject.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: ca050c139fe5eb9a58d3145a89ed58325a8c14e0 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_AppObject
  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  $table_name     テーブル名
  26.      *  @return bool    true:成功 false:失敗
  27.      */
  28.     function generate($table_name)
  29.     {
  30.         $table_id preg_replace('/_(.)/e'"strtoupper('\$1')"ucfirst($table_name));
  31.  
  32.         $app_dir $this->ctl->getDirectory('app');
  33.         $app_path ucfirst($this->ctl->getAppId()) '_' $table_id .'.php';
  34.  
  35.         $macro array();
  36.         $macro['project_id'$this->ctl->getAppId();
  37.         $macro['app_path'$app_path;
  38.         $macro['app_object'ucfirst($this->ctl->getAppId()) '_' $table_id;
  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_object.php"$path$macro== false{
  48.             printf("[warning] file creation failed [%s]\n"$path);
  49.         else {
  50.             printf("app-object script(s) successfully created [%s]\n"$path);
  51.         }
  52.     }
  53. }
  54. // }}}

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