core/xpdo/om/xpdogenerator.class.php
Class for reverse and forward engineering xPDO domain models.
- Package
- xpdo
- Subpackage
- om
\xPDOGenerator
A service for reverse and forward engineering xPDO domain models.
This service utilizes an xPDOManager instance to generate class stub and meta-data map files from a provided vanilla XML schema of a database structure. It can also reverse-engineer XML schemas from an existing database.
- Children
- \xPDOGenerator_sqlite
- \xPDOGenerator_mysql
- \xPDOGenerator_sqlsrv
- Abstract
Properties
string
$className= ''''
''
Details- Type
- string
string
$classTemplate= ''''
''
Details- Type
- string
string
$indexName= ''''
''
Details- Type
- string
\xPDOManager
$manager= 'null'
null
Details- Type
- \xPDOManager
string
$mapFooter= ''''
''
Details- Type
- string
string
$mapHeader= ''''
''
Details- Type
- string
string
$metaTemplate= ''''
''
Details- Type
- string
string
$outputDir= ''''
''
Details- Type
- string
string
$platformTemplate= ''''
''
Details- Type
- string
string
$schemaContent= ''''
''
Details- Type
- string
Methods
__construct(
\xPDOManager $manager
)
:
\xPDOGenerator
Constructor
Name | Type | Description |
---|---|---|
$manager | \xPDOManager | &$manager A reference to a valid xPDOManager instance. |
Type | Description |
---|---|
\xPDOGenerator |
- Access
- protected
_handleCData(
$parser, $data
)
:
void
Handles the XML CDATA tags
Name | Type | Description |
---|---|---|
$parser | ||
$data |
- Access
- protected
_handleCloseElement(
$parser, $element
)
:
void
Handles the closing of XML tags.
Name | Type | Description |
---|---|---|
$parser | ||
$element |
- Access
- protected
_handleOpenElement(
\xmlParser $parser, string $element, array $attributes
)
:
void
Handles formatting of the open XML element.
Name | Type | Description |
---|---|---|
$parser | \xmlParser | &$parser |
$element | string | &$element |
$attributes | array | &$attributes |
- Access
- protected
compile(
string $path
=
''
)
:
boolean
Compile the packages into a single file for quicker loading.
Name | Type | Description |
---|---|---|
$path | string | The absolute path to compile into. |
Type | Description |
---|---|
boolean | True if the compiling went successfully. |
- Abstract
- Access
- public
getClassName(
string $string
)
:
string
Gets a class name from a table name by splitting the string by _ and capitalizing each token.
Name | Type | Description |
---|---|---|
$string | string | The table name to format. |
Type | Description |
---|---|
string | The formatted string. |
- Access
- public
getClassPlatformTemplate(
$platform
)
:
string
Return the class platform template for the class files.
Name | Type | Description |
---|---|---|
$platform |
Type | Description |
---|---|
string | The class platform template. |
- Access
- public
getClassTemplate(
)
:
string
Return the class template for the class files.
Type | Description |
---|---|
string | The class template. |
- Access
- public
getDefault(
string $value
)
:
string
Format the passed default value as an XML attribute.
Override this in different PDO driver implementations if necessary.
Name | Type | Description |
---|---|---|
$value | string | The value to encapsulate in the default tag. |
Type | Description |
---|---|
string | The parsed XML string |
- Access
- public
getIndex(
string $index
)
:
string
Format the passed database index value as an XML attribute.
Name | Type | Description |
---|---|---|
$index | string | The DB representation string of the index |
Type | Description |
---|---|
string | The formatted XML attribute string |
- Abstract
- Implement this for specific PDO driver implementations.
- Access
- public
getMapFooter(
)
:
string
Gets the map footer template.
Type | Description |
---|---|
string | The map footer template. |
- Access
- public
getMapHeader(
)
:
string
Gets the map header template.
Type | Description |
---|---|
string | The map header template. |
- Access
- public
getMetaTemplate(
)
:
string
Gets the meta template.
Type | Description |
---|---|
string | The meta template. |
- Access
- public
getTableName(
string $string, string $prefix
=
'', boolean $prefixRequired
=
false
)
:
string
Formats a class name to a specific value, stripping the prefix if specified.
Name | Type | Description |
---|---|---|
$string | string | The name to format. |
$prefix | string | If specified, will strip the prefix out of the first argument. |
$prefixRequired | boolean | If true, will return a blank string if the prefix specified is not found. |
Type | Description |
---|---|
string | The formatting string. |
- Access
- public
outputClasses(
string $path
)
:
void
Write the generated class files to the specified path.
Name | Type | Description |
---|---|---|
$path | string | An absolute path to write the generated class files to. |
- Access
- public
outputMaps(
string $path
)
:
void
Write the generated class maps to the specified path.
Name | Type | Description |
---|---|---|
$path | string | An absolute path to write the generated maps to. |
- Access
- public
outputMeta(
string $path
)
:
bool
Write the generated meta map to the specified path.
Name | Type | Description |
---|---|---|
$path | string | An absolute path to write the generated maps to. |
Type | Description |
---|---|
bool |
parseSchema(
string $schemaFile, string $outputDir
=
'', boolean $compile
=
false
)
:
boolean
Parses an XPDO XML schema and generates classes and map files from it.
Name | Type | Description |
---|---|---|
$schemaFile | string | The name of the XML file representing the schema. |
$outputDir | string | The directory in which to generate the class and map files into. |
$compile | boolean | Create compiled copies of the classes and maps from the schema. |
Type | Description |
---|---|
boolean | True on success, false on failure. |