Source for file AddAppObject.php

Documentation is available at AddAppObject.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  AddAppObject.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: dd5a7a8bdef949d9e2c7d2292a7548a534dc1a3d $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Handle_AddAppObject
  13. /**
  14.  *  add-app-object handler
  15.  *
  16.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  add app-object
  23.      *
  24.      *  @access public
  25.      */
  26.     function perform()
  27.     {
  28.         return $this->_perform('AppObject');
  29.     }
  30.  
  31.     /**
  32.      *  @access protected
  33.      */
  34.     function _perform($target)
  35.     {
  36.         $r $this->_getopt(array('basedir='));
  37.         if (Ethna::isError($r)) {
  38.             return $r;
  39.         }
  40.         list($opt_list$arg_list$r;
  41.  
  42.         // table_name
  43.         $table_name array_shift($arg_list);
  44.         if ($table_name == null{
  45.             return Ethna::raiseError('table name isn\'t set.''usage');
  46.         }
  47.  
  48.         // basedir
  49.         if (isset($opt_list['basedir'])) {
  50.             $basedir realpath(end($opt_list['basedir']));
  51.         else {
  52.             $basedir getcwd();
  53.         }
  54.  
  55.         $r Ethna_Generator::generate($target$basedir$table_name);
  56.         if (Ethna::isError($r)) {
  57.             printf("error occurred while generating skelton. please see also following error message(s)\n\n");
  58.             return $r;
  59.         }
  60.  
  61.         return true;
  62.     }
  63.  
  64.     /**
  65.      *  get handler's description
  66.      *
  67.      *  @access public
  68.      */
  69.     function getDescription()
  70.     {
  71.         return <<<EOS
  72. add new app-object to project:
  73.     {$this->id} [-b|--basedir=dir] [table name]
  74.  
  75. EOS;
  76.     }
  77.  
  78.     /**
  79.      *  get usage
  80.      *
  81.      *  @access public
  82.      */
  83.     function getUsage()
  84.     {
  85.         return <<<EOS
  86. ethna {$this->id} [-b|--basedir=dir] [table name]
  87. EOS;
  88.     }
  89. }
  90. // }}}

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