Permalink
Browse files

Fix Versionable behavior

  • Loading branch information...
1 parent 64dca71 commit 4702164dd77d65bba18067c1d450b24b97a091d0 @jaugustin jaugustin committed Jan 13, 2013
@@ -406,7 +406,7 @@ public function populateFromVersion(\$version, \$con = null, &\$loadedObjects =
$fkColumnIds = $this->behavior->getReferrerIdsColumn($fk);
$fkColumnVersions = $this->behavior->getReferrerVersionsColumn($fk);
$relatedVersionQueryClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($foreignVersionTable));
- $relatedVersionTableMapClassName = $this->builder->getTableMapClassName();
+ $relatedVersionTableMapClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewTableMapBuilder($foreignVersionTable));
$relatedClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($foreignTable));
$fkColumn = $fk->getForeignColumn();
$fkVersionColumn = $foreignVersionTable->getColumn($this->behavior->getParameter('version_column'));
@@ -509,6 +509,8 @@ protected function addGetAllVersions(&$script)
{
$versionTable = $this->behavior->getVersionTable();
$versionARClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($versionTable));
+ //this force the use statment for VersionTableMap
+ $this->builder->getClassNameFromBuilder($this->builder->getNewTableMapBuilder($versionTable));
$versionForeignColumn = $versionTable->getColumn($this->behavior->getParameter('version_column'));
$fks = $versionTable->getForeignKeysReferencingTable($this->table->getName());
$relCol = $this->builder->getRefFKPhpNameAffix($fks[0], true);
@@ -664,6 +666,7 @@ protected function addGetLastVersions(&$script)
{
$versionTable = $this->behavior->getVersionTable();
$versionARClassName = $this->builder->getNewStubObjectBuilder($versionTable)->getClassName();
+ $versionTableMapClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewTableMapBuilder($versionTable));
$versionForeignColumn = $versionTable->getColumn($this->behavior->getParameter('version_column'));
$fks = $versionTable->getForeignKeysReferencingTable($this->table->getName());
$relCol = $this->builder->getRefFKPhpNameAffix($fks[0], $plural = true);
@@ -679,7 +682,7 @@ protected function addGetLastVersions(&$script)
public function getLastVersions(\$number = 10, \$criteria = null, \$con = null)
{
\$criteria = {$this->getVersionQueryClassName()}::create(null, \$criteria);
- \$criteria->addDescendingOrderByColumn({$versionARClassName}::VERSION);
+ \$criteria->addDescendingOrderByColumn({$versionTableMapClassName}::VERSION);
\$criteria->limit(\$number);
return \$this->{$versionGetter}(\$criteria, \$con);
@@ -14,6 +14,7 @@
use Propel\Generator\Builder\Om\ObjectBuilder;
use Propel\Generator\Builder\Om\PeerBuilder;
use Propel\Generator\Builder\Om\QueryBuilder;
+use Propel\Generator\Builder\Om\TableMapBuilder;
use Propel\Generator\Builder\Sql\DataSQLBuilder;
use Propel\Generator\Config\GeneratorConfigInterface;
use Propel\Generator\Model\Database;
@@ -403,6 +404,15 @@ public function getNewStubQueryInheritanceBuilder($child)
}
/**
+ * Returns new stub Query Inheritance builder class for this table.
+ * @return TableMapBuilder
+ */
+ public function getNewTableMapBuilder(Table $table)
+ {
+ return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'tablemap');
+ }
+
+ /**
* Gets the GeneratorConfig object.
*
* @return GeneratorConfigInterface

0 comments on commit 4702164

Please sign in to comment.