/** * Gets the package for the [base] object classes. * @return string */ public function getPackage() { return parent::getPackage() . ".om"; }
/** * Gets the package for the map builder classes. * @return string */ public function getPackage() { return parent::getPackage() . '.map'; }
/** * Adds the addInitialize() method to the table map class. * @param string &$script The script will be modified in this method. */ protected function addInitialize(&$script) { $table = $this->getTable(); $platform = $this->getPlatform(); $script .= "\n\t/**\n\t * Initialize the table attributes, columns and validators\n\t * Relations are not initialized by this method since they are lazy loaded\n\t *\n\t * @return void\n\t * @throws PropelException\n\t */\n\tpublic function initialize()\n\t{\n\t // attributes\n\t\t\$this->setName('" . $table->getName() . "');\n\t\t\$this->setPhpName('" . $table->getPhpName() . "');\n\t\t\$this->setClassname('" . addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassname()) . "');\n\t\t\$this->setPackage('" . parent::getPackage() . "');"; if ($table->getIdMethod() == "native") { $script .= "\n\t\t\$this->setUseIdGenerator(true);"; } else { $script .= "\n\t\t\$this->setUseIdGenerator(false);"; } if ($table->getIdMethodParameters()) { $params = $table->getIdMethodParameters(); $imp = $params[0]; $script .= "\n\t\t\$this->setPrimaryKeyMethodInfo('" . $imp->getValue() . "');"; } elseif ($table->getIdMethod() == IDMethod::NATIVE && ($platform->getNativeIdMethod() == PropelPlatformInterface::SEQUENCE || $platform->getNativeIdMethod() == PropelPlatformInterface::SERIAL)) { $script .= "\n\t\t\$this->setPrimaryKeyMethodInfo('" . $platform->getSequenceName($table) . "');"; } if ($this->getTable()->getChildrenColumn()) { $script .= "\n\t\t\$this->setSingleTableInheritance(true);"; } // Add columns to map $script .= "\n\t\t// columns"; foreach ($table->getColumns() as $col) { $cup = strtoupper($col->getName()); $cfc = $col->getPhpName(); if (!$col->getSize()) { $size = "null"; } else { $size = $col->getSize(); } $default = $col->getDefaultValueString(); if ($col->isPrimaryKey()) { if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= "\n\t\t\$this->addForeignPrimaryKey('{$cup}', '{$cfc}', '" . $col->getType() . "' , '" . $fk->getForeignTableName() . "', '" . strtoupper($fk->getMappedForeignColumn($col->getName())) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", {$default});"; } } else { $script .= "\n\t\t\$this->addPrimaryKey('{$cup}', '{$cfc}', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", {$default});"; } } else { if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= "\n\t\t\$this->addForeignKey('{$cup}', '{$cfc}', '" . $col->getType() . "', '" . $fk->getForeignTableName() . "', '" . strtoupper($fk->getMappedForeignColumn($col->getName())) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", {$default});"; } } else { $script .= "\n\t\t\$this->addColumn('{$cup}', '{$cfc}', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", {$default});"; } } // if col-is prim key if ($col->isEnumType()) { $script .= "\n\t\t\$this->getColumn('{$cup}', false)->setValueSet(" . var_export($col->getValueSet(), true) . ");"; } if ($col->isPrimaryString()) { $script .= "\n\t\t\$this->getColumn('{$cup}', false)->setPrimaryString(true);"; } } // foreach // validators $script .= "\n\t\t// validators"; foreach ($table->getValidators() as $val) { $col = $val->getColumn(); $cup = strtoupper($col->getName()); foreach ($val->getRules() as $rule) { if ($val->getTranslate() !== Validator::TRANSLATE_NONE) { $script .= "\n\t\t\$this->addValidator('{$cup}', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\\'", $rule->getValue()) . "', " . $val->getTranslate() . "('" . str_replace("'", "\\'", $rule->getMessage()) . "'));"; } else { $script .= "\n\t\t\$this->addValidator('{$cup}', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\\'", $rule->getValue()) . "', '" . str_replace("'", "\\'", $rule->getMessage()) . "');"; } // if ($rule->getTranslation() ... } // foreach rule } // foreach validator $script .= "\n\t} // initialize()\n"; }
/** * Gets the package for the [base] object classes. * @return string */ public function getPackage() { return ($this->getChild()->getPackage() ? $this->getChild()->getPackage() : parent::getPackage()) . ".om"; }
/** * Gets the package for the [base] object classes. * @return string */ public function getPackage() { return $this->getChild()->getPackage() ? $this->getChild()->getPackage() : parent::getPackage(); }
/** * Adds the addInitialize() method to the table map class. * @param string &$script The script will be modified in this method. */ protected function addInitialize(&$script) { $table = $this->getTable(); $platform = $this->getPlatform(); $ddlBuilder = $this->getDDLBuilder(); $script .= " /** * Initialize the table attributes, columns and validators * Relations are not initialized by this method since they are lazy loaded * * @return void * @throws PropelException */ public function initialize() { // attributes \$this->setName('".$table->getName()."'); \$this->setPhpName('".$table->getPhpName()."'); \$this->setClassname('" . $this->getObjectClassname() . "'); \$this->setPackage('" . parent::getPackage() . "');"; if ($table->getIdMethod() == "native") { $script .= " \$this->setUseIdGenerator(true);"; } else { $script .= " \$this->setUseIdGenerator(false);"; } if ($table->getIdMethodParameters()) { $params = $table->getIdMethodParameters(); $imp = $params[0]; $script .= " \$this->setPrimaryKeyMethodInfo('".$imp->getValue()."');"; } elseif ($table->getIdMethod() == IDMethod::NATIVE && ($platform->getNativeIdMethod() == Platform::SEQUENCE || $platform->getNativeIdMethod() == Platform::SERIAL)) { $script .= " \$this->setPrimaryKeyMethodInfo('".$this->prefixTablename($ddlBuilder->getSequenceName())."');"; } // Add columns to map $script .= " // columns"; foreach ($table->getColumns() as $col) { $cup=strtoupper($col->getName()); $cfc=$col->getPhpName(); if (!$col->getSize()) { $size = "null"; } else { $size = $col->getSize(); } $default = $col->getDefaultValueString(); if ($col->isPrimaryKey()) { if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= " \$this->addForeignPrimaryKey('$cup', '$cfc', '".$col->getType()."' , '".$fk->getForeignTableName()."', '".strtoupper($fk->getMappedForeignColumn($col->getName()))."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);"; } } else { $script .= " \$this->addPrimaryKey('$cup', '$cfc', '".$col->getType()."', ".var_export($col->isNotNull(), true).", ".$size.", $default);"; } } else { if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= " \$this->addForeignKey('$cup', '$cfc', '".$col->getType()."', '".$fk->getForeignTableName()."', '".strtoupper($fk->getMappedForeignColumn($col->getName()))."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);"; } } else { $script .= " \$this->addColumn('$cup', '$cfc', '".$col->getType()."', ".var_export($col->isNotNull(), true).", ".$size.", $default);"; } } // if col-is prim key } // foreach // validators $script .= " // validators"; foreach ($table->getValidators() as $val) { $col = $val->getColumn(); $cup = strtoupper($col->getName()); foreach ($val->getRules() as $rule) { if ($val->getTranslate() !== Validator::TRANSLATE_NONE) { $script .= " \$this->addValidator('$cup', '".$rule->getName()."', '".$rule->getClass()."', '".str_replace("'", "\'", $rule->getValue())."', ".$val->getTranslate()."('".str_replace("'", "\'", $rule->getMessage())."'));"; } else { $script .= " \$this->addValidator('$cup', '".$rule->getName()."', '".$rule->getClass()."', '".str_replace("'", "\'", $rule->getValue())."', '".str_replace("'", "\'", $rule->getMessage())."');"; } // if ($rule->getTranslation() ... } // foreach rule } // foreach validator $script .= " } // initialize() "; }