Commit b4ad6038 authored by zYne's avatar zYne

--no commit message

--no commit message
parent ccc51c72
......@@ -78,7 +78,6 @@ class Doctrine_Import_Builder
* This is a template that was previously in Builder/Record.tpl. Due to the fact
* that it was not bundled when compiling, it had to be moved here.
*
* @access public
* @return void
*/
public function loadTemplate()
......@@ -114,7 +113,6 @@ END;
*
* @param string $table
* @param array $tableColumns
* @access public
*/
public function buildDefinition($table, $tableColumns)
{
......@@ -201,20 +199,4 @@ END;
throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $fileName);
}
}
/**
*
* @param Doctrine_Schema_Object $schema
* @throws Doctrine_Import_Exception
* @return void
*/
public function build(Doctrine_Schema_Object $schema)
{
foreach ($schema->getDatabases() as $database){
foreach ($database->getTables() as $table){
$this->buildRecord($table);
}
}
}
}
......@@ -1385,7 +1385,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
public function loadTemplate($template)
{
$tpl = new $template($this->_table);
$tpl = new $template();
$tpl->setTable($this->_table);
$tpl->setUp();
$tpl->setTableDefinition();
return $this;
......
......@@ -101,6 +101,20 @@ class Doctrine_Relation_Parser
throw new Doctrine_Relation_Exception('Relation type not set.');
}
if (strpos($name, '[Component]') !== false) {
$name = str_replace('[Component]', $this->_table->getComponentName(), $name);
$templateName = substr($name, strlen($this->_table->getComponentName()));
if (substr($name, -8) === 'Template') {
$name = substr($name, 0, -8);
}
if ( ! class_exists($name)) {
$template = new $templateName();
print_r($template->getTable()->getColumns());
}
}
$this->_pending[$alias] = array_merge($options, array('class' => $name, 'alias' => $alias));
$m = Doctrine_Manager::getInstance();
......@@ -332,7 +346,7 @@ class Doctrine_Relation_Parser
if ($def['local'] !== $this->_table->getIdentifier()) {
$def['localKey'] = true;
}
}
}
} else {
if (isset($def['foreign'])) {
// local key not set, but foreign key is set
......
This diff is collapsed.
......@@ -37,11 +37,11 @@ class Doctrine_Template extends Doctrine_Record_Abstract
*/
protected $_table;
/**
* constructor, creates tree with reference to table and any options
* setTable
*
* @param Doctrine_Table $_table the table object this Template belongs to
*/
public function __construct(Doctrine_Table $table)
public function setTable(Doctrine_Table $table)
{
$this->_table = $table;
}
......
......@@ -30,27 +30,12 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Validator
class Doctrine_Validator extends Doctrine_Object
{
/**
* @var array $validators an array of validator objects
*/
private static $validators = array();
/**
* @var Doctrine_Null $null a Doctrine_Null object used for extremely fast
* null value testing
*/
private static $null;
/**
* initNullObject
*
* @param Doctrine_Null $null
* @return void
*/
public static function initNullObject(Doctrine_Null $null)
{
self::$null = $null;
}
/**
* returns a validator object
*
......@@ -90,14 +75,15 @@ class Doctrine_Validator
$err = array();
foreach ($data as $key => $value) {
if ($value === self::$null)
if ($value === self::$_null) {
$value = null;
elseif ($value instanceof Doctrine_Record)
} elseif ($value instanceof Doctrine_Record) {
$value = $value->getIncremented();
}
$column = $columns[$key];
if ($column[0] == "enum") {
if ($column['type'] == 'enum') {
$value = $record->getTable()->enumIndex($key, $value);
if ($value === false) {
......@@ -114,24 +100,7 @@ class Doctrine_Validator
}
}
if ( ! is_array($column[2])) {
$e = explode("|",$column[2]);
} else {
$e = $column[2];
}
foreach ($e as $k => $arg) {
if (is_string($k)) {
$name = $k;
$args = $arg;
} else {
$args = explode(":",$arg);
$name = array_shift($args);
if ( ! isset($args[0])) {
$args[0] = '';
}
}
foreach ($column as $name => $args) {
if (empty($name)
|| $name == 'primary'
|| $name == 'protected'
......@@ -139,8 +108,7 @@ class Doctrine_Validator
|| $name == 'default'
|| $name == 'values'
|| $name == 'sequence'
|| $name == 'zerofill'
) {
|| $name == 'zerofill') {
continue;
}
if (strtolower($name) == 'length') {
......@@ -154,7 +122,7 @@ class Doctrine_Validator
if (strtolower($name) == 'type') {
if (!$record->getTable()->getAttribute(Doctrine::ATTR_AUTO_TYPE_VLD)) {
if ( ! self::isValidType($value, $column[0])) {
if ( ! self::isValidType($value, $column['type'])) {
$errorStack->add($key, 'type');
}
}
......@@ -173,7 +141,7 @@ class Doctrine_Validator
}
if ($record->getTable()->getAttribute(Doctrine::ATTR_AUTO_TYPE_VLD)) {
if ( ! self::isValidType($value, $column[0])) {
if ( ! self::isValidType($value, $column['type'])) {
$errorStack->add($key, 'type');
continue;
}
......@@ -185,15 +153,15 @@ class Doctrine_Validator
*/
private function validateLength($column, $key, $value)
{
if ($column[0] == "timestamp" || $column[0] == "integer") {
if ($column['type'] == 'timestamp' || $column['type'] == 'integer') {
return true;
} else if ($column[0] == "array" || $column[0] == "object") {
} elseif ($column['type'] == 'array' || $column['type'] == 'object') {
$length = strlen(serialize($value));
} else {
$length = strlen($value);
}
if ($length > $column[1]) {
if ($length > $column['length']) {
return false;
}
return true;
......@@ -240,8 +208,9 @@ class Doctrine_Validator
*/
public static function isValidType($var, $type)
{
if ($type == 'boolean')
if ($type == 'boolean') {
return true;
}
$looseType = self::gettype($var);
$type = self::phpType($type);
......@@ -250,8 +219,9 @@ class Doctrine_Validator
case 'float':
case 'double':
case 'integer':
if ($type == 'string' || $type == 'float')
if ($type == 'string' || $type == 'float') {
return true;
}
case 'string':
case 'array':
case 'object':
......
......@@ -32,8 +32,12 @@
*/
class Doctrine_Template_TestCase extends Doctrine_UnitTestCase
{
public function testTemplateRelationsSupportConcreteInheritance()
{
$blog = new Blog();
$blog = new Blog();
$this->conn->export->exportClassesSql(array('Blog'));
}
}
......@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Ticket330_TestCase());
*/
/** */
/** */
// Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
......@@ -302,14 +302,15 @@ $test->addTestCase(new Doctrine_Query_TestCase());
$test->addTestCase(new Doctrine_Ticket364_TestCase());
$test->addTestCase(new Doctrine_Template_TestCase());
$test->addTestCase(new Doctrine_Query_MysqlSubquery_TestCase());
$test->addTestCase(new Doctrine_Query_PgsqlSubquery_TestCase());
$test->addTestCase(new Doctrine_Query_MysqlSubqueryHaving_TestCase());
/***/
/**
$test->addTestCase(new Doctrine_Template_TestCase());
*/
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment