xpdo/om/xpdogenerator.class.php
- package
- xpdo
- subpackage
- om
- Classes
- xPDOGenerator
Description
Class for reverse and forward engineering xPDO domain models.
\xPDOGenerator
- abstract
- package
- xpdo
- subpackage
- om
- Properties
- $className
- $classTemplate
- $classes
- $fieldKey
- $indexName
- $manager
- $map
- $mapFooter
- $mapHeader
- $model
- $outputDir
- $platformTemplate
- $schemaContent
- $schemaFile
- $schemaManager
- $xmlParser
- Methods
- __construct
- _handleCData
- _handleCloseElement
- _handleOpenElement
- compile
- getClassName
- getClassPlatformTemplate
- getClassTemplate
- getDefault
- getIndex
- getMapFooter
- getMapHeader
- getTableName
- outputClasses
- outputMaps
- parseSchema
Description
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.
Properties
$className
string $className = ''
Details
- string
A placeholder for the current class name. - visibility
- public
- default
- final
- false
- static
- false
$classTemplate
string $classTemplate = ''
Details
- string
The class template string to build the class files from. - visibility
- public
- default
- final
- false
- static
- false
$classes
array $classes = 'array'
Details
- array
The stored classes array. - visibility
- public
- default
- array
- final
- false
- static
- false
$fieldKey
string $fieldKey = ''
Details
- string
A placeholder for the current field key. - visibility
- public
- default
- final
- false
- static
- false
$indexName
string $indexName = ''
Details
- string
A placeholder for the current index name. - visibility
- public
- default
- final
- false
- static
- false
$manager
\xPDOManager $manager = 'null'
Details
-
\xPDOManager
A reference to the xPDOManager using this generator. - visibility
- public
- default
- null
- final
- false
- static
- false
$map
array $map = 'array'
Details
- array
The stored map array. - visibility
- public
- default
- array
- final
- false
- static
- false
$mapFooter
string $mapFooter = ''
Details
- string
The map footer string to build the map files from. - visibility
- public
- default
- final
- false
- static
- false
$mapHeader
string $mapHeader = ''
Details
- string
The map header string to build the map files from. - visibility
- public
- default
- final
- false
- static
- false
$model
array $model = 'array'
Details
- array
The stored model array. - visibility
- public
- default
- array
- final
- false
- static
- false
$outputDir
string $outputDir = ''
Details
- string
The absolute path to output the class and map files to. - visibility
- public
- default
- final
- false
- static
- false
$platformTemplate
string $platformTemplate = ''
Details
- string
The class platform template string to build the class platform files from. - visibility
- public
- default
- final
- false
- static
- false
$schemaContent
string $schemaContent = ''
Details
- string
The stored content of the newly-created schema file. - visibility
- public
- default
- final
- false
- static
- false
$schemaFile
string $schemaFile = ''
Details
- string
An absolute path to the schema file. - visibility
- public
- default
- final
- false
- static
- false
$schemaManager
\xPDOSchemaManager $schemaManager = 'null'
Details
- \xPDOSchemaManager
- visibility
- public
- default
- null
- final
- false
- static
- false
$xmlParser
\xmlParser $xmlParser = 'null'
Details
- \xmlParser
- visibility
- public
- default
- null
- final
- false
- static
- false
Methods
__construct
__construct(
\xPDOManager $manager
)
:
\xPDOGenerator
Constructor
Arguments
- $manager
- \xPDOManager
&$manager A reference to a valid xPDOManager instance.
Output
Details
- visibility
- public
- final
- false
- static
- false
- access
- protected
_handleCData
_handleCData(
$parser, $data
)
:
Handles the XML CDATA tags
Arguments
- $parser
- $data
Details
- visibility
- protected
- final
- false
- static
- false
- access
- protected
_handleCloseElement
_handleCloseElement(
$parser, $element
)
:
Handles the closing of XML tags.
Arguments
- $parser
- $element
Details
- visibility
- protected
- final
- false
- static
- false
- access
- protected
_handleOpenElement
_handleOpenElement(
\xmlParser $parser, string $element, array $attributes
)
:
Handles formatting of the open XML element.
Arguments
- $parser
- \xmlParser
&$parser - $element
- string
&$element - $attributes
- array
&$attributes
Details
- visibility
- protected
- final
- false
- static
- false
- access
- protected
compile
compile(
string $path
)
:
boolean
Compile the packages into a single file for quicker loading.
Arguments
- $path
- string
The absolute path to compile into.
Output
- boolean
- True if the compiling went successfully.
Details
- visibility
- public
- final
- false
- static
- false
- abstract
- access
- public
getClassName
getClassName(
string $string
)
:
string
Gets a class name from a table name by splitting the string by _ and capitalizing each token.
Arguments
- $string
- string
The table name to format.
Output
- string
- The formatted string.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getClassPlatformTemplate
getClassPlatformTemplate(
$platform
)
:
string
Return the class platform template for the class files.
Arguments
- $platform
Output
- string
- The class platform template.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getClassTemplate
getClassTemplate(
)
:
string
Return the class template for the class files.
Output
- string
- The class template.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getDefault
getDefault(
string $value
)
:
string
Format the passed default value as an XML attribute.
Override this in different PDO driver implementations if necessary.
Arguments
- $value
- string
The value to encapsulate in the default tag.
Output
- string
- The parsed XML string
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getIndex
getIndex(
string $index
)
:
string
Format the passed database index value as an XML attribute.
Arguments
- $index
- string
The DB representation string of the index
Output
- string
- The formatted XML attribute string
Details
- visibility
- public
- final
- false
- static
- false
- abstract
- Implement this for specific PDO driver implementations.
- access
- public
getMapFooter
getMapFooter(
)
:
string
Gets the map footer template.
Output
- string
- The map footer template.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getMapHeader
getMapHeader(
)
:
string
Gets the map header template.
Output
- string
- The map header template.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getTableName
getTableName(
string $string, string $prefix, boolean $prefixRequired
=
false
)
:
string
Formats a class name to a specific value, stripping the prefix if specified.
Arguments
- $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.
Output
- string
- The formatting string.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
outputClasses
outputClasses(
string $path
)
:
Write the generated class files to the specified path.
Arguments
- $path
- string
An absolute path to write the generated class files to.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
outputMaps
outputMaps(
string $path
)
:
Write the generated class maps to the specified path.
Arguments
- $path
- string
An absolute path to write the generated maps to.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
parseSchema
parseSchema(
string $schemaFile, string $outputDir, boolean $compile
=
false
)
:
boolean
Parses an XPDO XML schema and generates classes and map files from it.
Arguments
- $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.
Output
- boolean
- True on success, false on failure.
Details
- visibility
- public
- final
- false
- static
- false