1: <?php
 2:     /**
 3:      * QCodeGen
 4:      * 
 5:      * Feel free to override any core QCodeGenBase methods here
 6:      * 
 7:      * @package Codegen   
 8:      * @author Qcubed
 9:      * @copyright 
10:      * @version 2011
11:      * @access public
12:      */
13:      
14:     require(__QCUBED_CORE__ . '/codegen/QCodeGenBase.class.php');     
15:     
16:     /**
17:      * QCodeGen
18:      * 
19:      * Feel free to override any core QCodeGenBase methods here
20:      * 
21:      * @package Codegen   
22:      * @author Qcubed
23:      * @copyright 
24:      * @version 2011
25:      * @access public
26:      */
27:     class QCodeGen extends QCodeGenBase {
28:         
29:         /**
30:          * Construct the QCodeGen object.
31:          * 
32:          * Gives you an opportunity to read your xml file and make codegen changes accordingly.
33:          */
34:         public function __construct($objSettingsXml) {
35:             // Specify the paths to your template files here. These paths will be searched in the order declared, to
36:             // find a particular template file. Template files found lower down in the order will override the previous ones.
37:             static::$TemplatePaths = array (
38:                 __QCUBED_CORE__ . '/codegen/templates/',
39:                 __QCUBED__ . '/codegen/templates/'
40:             );
41:         }
42:                 
43:         /**
44:          * QCodeGen::Pluralize()
45:          * 
46:          * Example: Overriding the Pluralize method
47:          * 
48:          * @param string $strName
49:          * @return string
50:          */
51:         protected function Pluralize($strName) {
52:             // Special Rules go Here
53:             switch (true) {
54:                 case ($strName == 'person'):
55:                     return 'people';
56:                 case ($strName == 'Person'):
57:                     return 'People';
58:                 case ($strName == 'PERSON'):
59:                     return 'PEOPLE';
60: 
61:                 // Trying to be cute here...
62:                 case (strtolower($strName) == 'fish'):
63:                     return $strName . 'ies';
64: 
65:                 // Otherwise, call parent
66:                 default:
67:                     return parent::Pluralize($strName);
68:             }
69:         }
70:     }
71: 
72:     require(__QCUBED_CORE__ . '/codegen/library.inc.php');