Overview

Packages

  • Actions
  • Codegen
  • Controls
    • Base
  • DatabaseAdapters
  • Events
  • None
  • Sessions
  • Tests

Classes

  • JqControlGen
  • QCodeGen
  • QCodeGenBase
  • QConvertNotation
  • QConvertNotationBase
  • QDatabaseCodeGen
  • QIndex
  • QManyToManyReference
  • QReference
  • QRestServiceCodeGen
  • QReverseReference
  • QSqlColumn
  • QSqlTable
  • QTypeTable
  • Overview
  • Package
  • Class

Class QCodeGenBase

This is the CodeGen class which performs the code generation for both the Object-Relational Model (e.g. Data Objects) as well as the draft Forms, which make up simple HTML/PHP scripts to perform basic CRUD functionality on each object.

QBaseClass
Extended by QCodeGenBase

Direct known subclasses

JqControlGen, QCodeGen

Indirect known subclasses

QDatabaseCodeGen, QRestServiceCodeGen
Abstract
Package: Codegen
Located at includes/codegen/QCodeGenBase.class.php
Methods summary
public static string
# GetSettingsXml( )

Gets the settings in codegen_settings.xml file and returns its text without comments

Gets the settings in codegen_settings.xml file and returns its text without comments

Returns

string
public static
# Run( string $strSettingsXmlFilePath )

The function which actually performs the steps for code generation Code generation begins here.

The function which actually performs the steps for code generation Code generation begins here.

Parameters

$strSettingsXmlFilePath
Path to the settings file
public static mixed
# LookupSetting( SimpleXmlElement $objNode, string $strTagName, string $strAttributeName = null, string $strType = QType::String )

This will lookup either the node value (if no attributename is passed in) or the attribute value for a given Tag. Node Searches only apply from the root level of the configuration XML being passed in (e.g. it will not be able to lookup the tag name of a grandchild of the root node)

This will lookup either the node value (if no attributename is passed in) or the attribute value for a given Tag. Node Searches only apply from the root level of the configuration XML being passed in (e.g. it will not be able to lookup the tag name of a grandchild of the root node)

If No Tag Name is passed in, then attribute/value lookup is based on the root node, itself.

Parameters

$objNode
$strTagName
$strAttributeName
$strType

Returns

mixed
the return type depends on the QType you pass in to $strType
public static array
# GenerateAggregate( )

Returns

array
public boolean
# GenerateFiles( string $strTemplatePrefix, mixed[] $mixArgumentArray )

Given a template prefix (e.g. db_orm_, db_type_, rest_, soap_, etc.), pull all the _*.tpl templates from any subfolders of the template prefix in QCodeGen::TemplatesPath and QCodeGen::TemplatesPathCustom, and call GenerateFile() on each one. If there are any template files that reside in BOTH TemplatesPath AND TemplatesPathCustom, then only use the TemplatesPathCustom one (which in essence overrides the one in TemplatesPath)

Given a template prefix (e.g. db_orm_, db_type_, rest_, soap_, etc.), pull all the _*.tpl templates from any subfolders of the template prefix in QCodeGen::TemplatesPath and QCodeGen::TemplatesPathCustom, and call GenerateFile() on each one. If there are any template files that reside in BOTH TemplatesPath AND TemplatesPathCustom, then only use the TemplatesPathCustom one (which in essence overrides the one in TemplatesPath)

Parameters

$strTemplatePrefix
the prefix of the templates you want to generate against
$mixArgumentArray
array of arguments to send to EvaluateTemplate

Returns

boolean
success/failure on whether or not all the files generated successfully

Throws

Exception
QCallerException
protected
# buildTemplateArray( $strTemplateFilePath, & $strTemplateArray )
protected SimpleXMLElement
# getTemplateSettings( null|string $strTemplateFilePath, null|string & $strTemplate = null )

Returns the settings of the template file as SimpleXMLElement object

Returns the settings of the template file as SimpleXMLElement object

Deprecated

Parameters

$strTemplateFilePath
Path to the file
$strTemplate
Text of the template (if $strTemplateFilePath is null, this field must be string)

Returns

SimpleXMLElement

Throws

Exception
public mixed
# GenerateFile( string $strModuleSubPath, string $strTemplateFilePath, mixed[] $mixArgumentArray, boolean $blnSave = true )

Generates a php code using a template file

Generates a php code using a template file

Parameters

$strModuleSubPath
$strTemplateFilePath
Path to the template file
$mixArgumentArray
$blnSave
whether or not to actually perform the save

Returns

mixed
returns the evaluated template or boolean save success.

Throws

QCallerException
Exception
protected
# setGeneratedFilePermissions( string $strFilePath )

Sets the file permissions (Linux only) for a file generated by the Code Generator

Sets the file permissions (Linux only) for a file generated by the Code Generator

Parameters

$strFilePath
Path of the generated file

Throws

QCallerException
protected mixed|string
# EvaluatePHP( $strFilename, $mixArgumentArray, null & $templateSettings = null )

Returns the evaluated PHP

Returns the evaluated PHP

Parameters

$strFilename
$mixArgumentArray
$templateSettings

Returns

mixed|string
protected string
# ModelClassName( string $strTableName )

Given a table name, returns the name of the class for the corresponding model object.

Given a table name, returns the name of the class for the corresponding model object.

Parameters

$strTableName

Returns

string
public string
# ModelVariableName( string $strTableName )

Given a table name, returns a variable name that will be used to represent the corresponding model object.

Given a table name, returns a variable name that will be used to represent the corresponding model object.

Parameters

$strTableName

Returns

string
protected string
# ModelReverseReferenceVariableName( string $strTableName )

Given a table name, returns the variable name that will be used to refer to the object in a reverse reference context (many-to-one).

Given a table name, returns the variable name that will be used to refer to the object in a reverse reference context (many-to-one).

Parameters

$strTableName

Returns

string
protected string
# ModelReverseReferenceVariableType( $strTableName )

Given a table name, returns the variable type of the object in a reverse reference context (many-to-one).

Given a table name, returns the variable type of the object in a reverse reference context (many-to-one).

Parameters

$strTableName

Returns

string
protected string
# ModelColumnVariableName( QSqlColumn $objColumn )

Given a column, returns the name of the variable used to represent the column's value inside the model object.

Given a column, returns the name of the variable used to represent the column's value inside the model object.

Parameters

$objColumn

Returns

string
protected string
# ModelColumnPropertyName( string $strColumnName )

Return the name of the property corresponding to the given column name as used in the getter and setter of the model object.

Return the name of the property corresponding to the given column name as used in the getter and setter of the model object.

Parameters

$strColumnName

Returns

string
protected string
# TypeColumnPropertyName( string $strColumnName )

Return the name of the property corresponding to the given column name as used in the getter and setter of a Type object.

Return the name of the property corresponding to the given column name as used in the getter and setter of a Type object.

Parameters

$strColumnName
Column name

Returns

string
protected string
# ModelReferenceColumnName( string $strColumnName )

Given the name of a column that is a foreign key to another table, returns a kind of virtual column name that would refer to the object pointed to. This new name is not actually used, but derivatives of this name are used to represent a variable and property name that refers to this object that will get stored in the model.

Given the name of a column that is a foreign key to another table, returns a kind of virtual column name that would refer to the object pointed to. This new name is not actually used, but derivatives of this name are used to represent a variable and property name that refers to this object that will get stored in the model.

Parameters

$strColumnName

Returns

string
protected string
# ModelReferenceVariableName( string $strColumnName )

Given a column name to a foreign key, returns the name of the variable that will represent the foreign object stored in the model.

Given a column name to a foreign key, returns the name of the variable that will represent the foreign object stored in the model.

Parameters

$strColumnName

Returns

string
protected string
# ModelReferencePropertyName( string $strColumnName )

Given a column name to a foreign key, returns the name of the property that will be used in the getter and setter to represent the foreign object stored in the model.

Given a column name to a foreign key, returns the name of the property that will be used in the getter and setter to represent the foreign object stored in the model.

Parameters

$strColumnName

Returns

string
protected
# ParameterCleanupFromColumn( QSqlColumn $objColumn, $blnIncludeEquality = false )
protected
# ParameterListFromColumnArray( $objColumnArray )
protected
# ImplodeObjectArray( $strGlue, $strPrefix, $strSuffix, $strProperty, $objArrayToImplode )
protected
# TypeTokenFromTypeName( $strName )
public static string
# ModelConnectorControlName( QSqlColumn|QReverseReference|QManyToManyReference $objColumn )

Returns the control label name as used in the ModelConnector corresponding to this column or table.

Returns the control label name as used in the ModelConnector corresponding to this column or table.

Parameters

$objColumn

Returns

string
public static string
# ModelConnectorPropertyName( QSqlColumn|QReverseReference|QManyToManyReference $objColumn )

The property name used in the ModelConnector for the given column, virtual column or table

The property name used in the ModelConnector for the given column, virtual column or table

Parameters

$objColumn

Returns

string

Throws

Exception
public string
# ModelConnectorVariableName( QSqlColumn|QReverseReference|QManyToManyReference $objColumn )

Return a variable name corresponding to the given column, including virtual columns like QReverseReference and QManyToMany references.

Return a variable name corresponding to the given column, including virtual columns like QReverseReference and QManyToMany references.

Parameters

$objColumn

Returns

string
public string
# ModelConnectorLabelVariableName( QSqlColumn|QReverseReference|QManyToManyReference $objColumn )

Returns a variable name for the "label" version of a control, which would be the read-only version of viewing the data in the column.

Returns a variable name for the "label" version of a control, which would be the read-only version of viewing the data in the column.

Parameters

$objColumn

Returns

string
protected string
# ModelConnectorControlClass( QSqlColumn|QReverseReference|QManyToManyReference $objColumn )

Returns the class for the control that will be created to edit the given column, including the 'virtual' columns of reverse references (many to one) and many-to-many references.

Returns the class for the control that will be created to edit the given column, including the 'virtual' columns of reverse references (many to one) and many-to-many references.

Parameters

$objColumn

Returns

string
Class name of control which can handle this column's data

Throws

Exception
public
# DataListControlClass( QSqlTable $objTable )
public static string
# DataListControlName( QSqlTable $objTable )

Returns the control label name as used in the data list panel corresponding to this column.

Returns the control label name as used in the data list panel corresponding to this column.

Parameters

$objTable

Returns

string
public static string
# DataListItemName( QSqlTable $objTable )

Returns the name of an item in the data list as will be displayed in the edit panel.

Returns the name of an item in the data list as will be displayed in the edit panel.

Parameters

$objTable

Returns

string
public
# DataListVarName( QSqlTable $objTable )
public static
# DataListPropertyName( QSqlTable $objTable )
public static
# DataListPropertyNamePlural( QSqlTable $objTable )
public AbstractControl_CodeGenerator
# GetControlCodeGenerator( QSqlColumn|QReverseReference|QManyToManyReference $objColumn )

Returns the class for the control that will be created to edit the given column, including the 'virtual' columns of reverse references (many to one) and many-to-many references.

Returns the class for the control that will be created to edit the given column, including the 'virtual' columns of reverse references (many to one) and many-to-many references.

Parameters

$objColumn

Returns

AbstractControl_CodeGenerator
helper object

Throws

Exception
public
# GetDataListCodeGenerator( $objTable )
protected
# CalculateObjectMemberVariable( $strTableName, $strColumnName, $strReferencedTableName )
protected
# CalculateObjectPropertyName( $strTableName, $strColumnName, $strReferencedTableName )
protected
# CalculateObjectDescription( $strTableName, $strColumnName, $strReferencedTableName, $blnPluralize )
protected
# CalculateObjectDescriptionForAssociation( $strAssociationTableName, $strTableName, $strReferencedTableName, $blnPluralize )
protected
# CalculateGraphPrefixArray( $objForeignKeyArray )
protected string
# VariableTypeFromDbType( string $strDbType )

Returns the variable type corresponding to the database column type

Returns the variable type corresponding to the database column type

Parameters

$strDbType

Returns

string

Throws

Exception
protected string
# Pluralize( string $strName )

Return the plural of the given name. Override this and return the plural version of particular names if this generic version isn't working for you.

Return the plural of the given name. Override this and return the plural version of particular names if this generic version isn't working for you.

Parameters

$strName

Returns

string
public
# ReportError( $strError )
public mixed
# __get( string $strName )

Override method to perform a property "Get" This will get the value of $strName

Override method to perform a property "Get" This will get the value of $strName

Parameters

$strName

Returns

mixed

Throws

Exception|QCallerException

Overrides

QBaseClass::__get()
public mixed|
# __set( string $strName, string $mixValue )

PHP magic method to set class properties

PHP magic method to set class properties

Parameters

$strName
$mixValue

Returns

mixed|

Throws

QUndefinedPropertyException

Overrides

QBaseClass::__set()
Methods inherited from QBaseClass
OverrideAttributes(), __call()
Constants summary
string PhpReservedWords

PHP Reserved Words. They make up: Invalid Type names -- these are reserved words which cannot be Type names in any user type table Invalid Table names -- these are reserved words which cannot be used as any table name Please refer to : http://php.net/manual/en/reserved.php

PHP Reserved Words. They make up: Invalid Type names -- these are reserved words which cannot be Type names in any user type table Invalid Table names -- these are reserved words which cannot be used as any table name Please refer to : http://php.net/manual/en/reserved.php

# 'new, null, break, return, switch, self, case, const, clone, continue, declare, default, echo, else, elseif, empty, exit, eval, if, try, throw, catch, public, private, protected, function, extends, foreach, for, while, do, var, class, static, abstract, isset, unset, implements, interface, instanceof, include, include_once, require, require_once, abstract, and, or, xor, array, list, false, true, global, parent, print, exception, namespace, goto, final, endif, endswitch, enddeclare, endwhile, use, as, endfor, endforeach, this'
boolean DebugMode

DebugMode -- for Template Developers This will output the current evaluated template/statement to the screen On "eval" errors, you can click on the "View Rendered Page" to see what currently is being evaluated, which should hopefully aid in template debugging.

DebugMode -- for Template Developers This will output the current evaluated template/statement to the screen On "eval" errors, you can click on the "View Rendered Page" to see what currently is being evaluated, which should hopefully aid in template debugging.

# false
Properties summary
protected string $strClassPrefix

Class Prefix, as specified in the codegen_settings.xml file

Class Prefix, as specified in the codegen_settings.xml file

#
protected string $strClassSuffix

Class suffix, as specified in the codegen_settings.xml file

Class suffix, as specified in the codegen_settings.xml file

#
protected string $strErrors

Errors and Warnings collected during the process of codegen *

Errors and Warnings collected during the process of codegen *

#
protected string $strWarnings

Warnings collected during the codegen process.

Warnings collected during the codegen process.

#
public static array $TemplatePaths

The list of template base paths to search, in order, when looking for a particular template. Set this to insert new template paths. If not set, the default will be the project template path, following by the qcubed core path.

The list of template base paths to search, in order, when looking for a particular template. Set this to insert new template paths. If not set, the default will be the project template path, following by the qcubed core path.

#
public static QCodeGen[] $CodeGenArray

This static array contains an array of active and executed codegen objects, based on the XML Configuration passed in to Run()

This static array contains an array of active and executed codegen objects, based on the XML Configuration passed in to Run()

#
protected static string[] $SettingsXmlArray

This is the array representation of the parsed SettingsXml for reportback purposes.

This is the array representation of the parsed SettingsXml for reportback purposes.

#
protected static SimpleXmlElement $SettingsXml

This is the SimpleXML representation of the Settings XML file

This is the SimpleXML representation of the Settings XML file

#
public static $SettingsFilePath
#
public static string $ApplicationName

Application Name (from CodeGen Settings)

Application Name (from CodeGen Settings)

#
public static string $PreferredRenderMethod

Preferred Render Method (from CodeGen Settings)

Preferred Render Method (from CodeGen Settings)

#
public static string $CreateMethod

Create Method (from CodeGen Settings)

Create Method (from CodeGen Settings)

#
public static string $DefaultButtonClass

Default Button Class (from CodeGen Settings)

Default Button Class (from CodeGen Settings)

#
protected static string $TemplateEscapeBegin

Template Escape Begin (from CodeGen Settings)

Template Escape Begin (from CodeGen Settings)

#
protected static $TemplateEscapeBeginLength
#
protected static string $TemplateEscapeEnd

Template Escape End (from CodeGen Settings)

Template Escape End (from CodeGen Settings)

#
protected static $TemplateEscapeEndLength
#
public static string $RootErrors
# ''
protected static string[] $DirectoriesToExcludeArray

array of directories to be excluded in codegen (lower cased)

array of directories to be excluded in codegen (lower cased)

# array('.','..','.svn','svn','cvs','.git')
Magic properties summary
public string $Errors

List of errors

public string $Warnings

List of warnings

API documentation generated by ApiGen