protected $_baseClassName = 'IPF_ORM_Record';
protected $_generateAccessors = false;
protected static $_tpl;
-
public function __construct()
{
$this->loadTemplate();
if ($bool !== null) {
$this->_generateAccessors = $bool;
}
+
return $this->_generateAccessors;
}
}
self::$_tpl = '/**' . PHP_EOL
- . ' * This class has been auto-generated by the IPF ORM Framework' . PHP_EOL
+ . ' * This class has been auto-generated by the IPF_ORM Framework' . PHP_EOL
. ' */' . PHP_EOL
. '%sclass %s extends %s' . PHP_EOL
. '{'
if ($code) {
return ' public function setUp()' . PHP_EOL . ' {' . PHP_EOL . ' ' . $code . PHP_EOL . ' }';
}
+
}
public function buildColumns(array $columns)
unset($options['ntype']);
// Remove notnull => true if the column is primary
- // Primary columns are implied to be notnull in IPF
+ // Primary columns are implied to be notnull in IPF_ORM
if (isset($options['primary']) && $options['primary'] == true && (isset($options['notnull']) && $options['notnull'] == true)) {
unset($options['notnull']);
}
// Remove default if the value is 0 and the column is a primary key
- // IPF defaults to 0 if it is a primary key
+ // IPF_ORM defaults to 0 if it is a primary key
if (isset($options['primary']) && $options['primary'] == true && (isset($options['default']) && $options['default'] == 0)) {
unset($options['default']);
}
return PHP_EOL." ".'$this->addListener(new '.$listener.'());';
}
+
public function buildAttributes(array $attributes)
{
$build = PHP_EOL;
public function buildRecord(array $definition)
{
- if ( ! isset($definition['className'])) {
+ if ( !isset($definition['className'])) {
throw new IPF_ORM_Exception('Missing class name.');
}
-
$definition['topLevelClassName'] = $definition['className'];
-
if ($this->generateBaseClasses()) {
$definition['is_package'] = (isset($definition['package']) && $definition['package']) ? true:false;
$this->writeTableDefinition($definition['tableClassName'], $writePath, array('extends' => $definition['inheritance']['tableExtends']));
}
}
- // If it is the base class of the ipf record definition
+ // If it is the base class of the IPF_ORM record definition
else if (isset($definition['is_base_class']) && $definition['is_base_class']) {
// If it is a part of a package then we need to put it in a package subfolder
if (isset($definition['is_package']) && $definition['is_package']) {
'keyValue'));
protected $_validators = array();
+
public function getValidators()
{
if (empty($this->_validators)) {
$this->_validators = IPF_ORM_Utils::getValidators();
}
-
return $this->_validators;
}
$builder->setOptions($this->getOptions());
$array = $this->buildSchema($schema, $format);
-
+
foreach ($array as $name => $definition) {
+
if ( ! empty($models) && !in_array($definition['className'], $models)) {
continue;
}
- print " $name\n";
+ print " $name\n";
$builder->buildRecord($definition);
}
}
$moves = array('columns' => array());
foreach ($array as $className => $definition) {
+ if (!isset($definition['className']))
+ continue;
$parent = $this->_findBaseSuperClass($array, $definition['className']);
// Move any definitions on the schema to the parent
if (isset($definition['inheritance']['extends']) && isset($definition['inheritance']['type']) && ($definition['inheritance']['type'] == 'simple' || $definition['inheritance']['type'] == 'column_aggregation')) {
foreach ($relations as $alias => $relation) {
$class = isset($relation['class']) ? $relation['class']:$alias;
- if ( ! isset($array[$class])) {
+ if (!isset($array[$class])) {
continue;
}
$relation['class'] = $class;
// Make sure we do not have any duplicate relations
$this->_fixDuplicateRelations();
+ //$array['relations'];
// Set the full array of relationships for each class to the final array
foreach ($this->_relations as $className => $relations) {
$array[$className]['relations'] = $relations;
}
$validation = array_flip($validation);
-
foreach ($element as $key => $value) {
if ( ! isset($validation[$value])) {
throw new IPF_ORM_Exception(sprintf('Invalid schema element named "' . $value . '"