Permalink
Browse files

[Generator] move DEFAULT_STRING_FORMAT from Peer to TableMap

  • Loading branch information...
1 parent ea8dc52 commit ec3f9385843a880dce130e6f83ab22fc2696f889 @jaugustin jaugustin committed Jan 14, 2013
View
2 src/Propel/Generator/Builder/Om/ObjectBuilder.php
@@ -5121,7 +5121,7 @@ public function __toString()
*/
public function __toString()
{
- return (string) \$this->exportTo(" . $this->getPeerClassName() . "::DEFAULT_STRING_FORMAT);
+ return (string) \$this->exportTo(" . $this->getTableMapClassName() . "::DEFAULT_STRING_FORMAT);
}
";
}
View
3 src/Propel/Generator/Builder/Om/PeerBuilder.php
@@ -204,9 +204,6 @@ protected function addConstantsAndAttributes(&$script)
}
$script .= "
- /** The default string format for model objects of the related table **/
- const DEFAULT_STRING_FORMAT = '" . $this->getTable()->getDefaultStringFormat() . "';
-
/**
* An identity map to hold any loaded instances of ".$this->getObjectClassName()." objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
View
1 src/Propel/Generator/Builder/Om/TableMapBuilder.php
@@ -128,6 +128,7 @@ protected function addConstants()
'nbHydrateColumns' => $this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns(),
'peerClassName' => $this->getStubPeerBuilder()->getFullyQualifiedClassName(),
'columns' => $this->getTable()->getColumns(),
+ 'stringFormat' => $this->getTable()->getDefaultStringFormat(),
));
}
View
5 src/Propel/Generator/Builder/Om/templates/tableMapConstants.php
@@ -49,3 +49,8 @@
*/
const <?php echo $col->getConstantColumnName() ?> = '<?php echo $tableName ?>.<?php echo strtoupper($col->getName()) ?>';
<?php endforeach; ?>
+
+ /**
+ * The default string format for model objects of the related table
+ */
+ const DEFAULT_STRING_FORMAT = '<?php echo $stringFormat ?>';
View
4 src/Propel/Runtime/Collection/Collection.php
@@ -605,12 +605,12 @@ public function __call($name, $params)
/**
* Returns a string representation of the current collection.
* Based on the string representation of the underlying objects, defined in
- * the Peer::DEFAULT_STRING_FORMAT constant
+ * the TableMap::DEFAULT_STRING_FORMAT constant
*
* @return string
*/
public function __toString()
{
- return (string) $this->exportTo(constant($this->getPeerClass() . '::DEFAULT_STRING_FORMAT'));
+ return (string) $this->exportTo(constant($this->getTableMapClass() . '::DEFAULT_STRING_FORMAT'));
}
}
View
6 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerTest.php
@@ -104,9 +104,9 @@ public function testAddSelectColumnsAliasLazyLoad()
public function testDefaultStringFormatConstant()
{
- $this->assertTrue(defined('Propel\Tests\Bookstore\BookPeer::DEFAULT_STRING_FORMAT'), 'every Peer class has the DEFAULT_STRING_FORMAT constant');
- $this->assertEquals('YAML', AuthorPeer::DEFAULT_STRING_FORMAT, 'default string format is YAML by default');
- $this->assertEquals('XML', PublisherPeer::DEFAULT_STRING_FORMAT, 'default string format can be customized using the defaultStringFormat attribute in the schema');
+ $this->assertTrue(defined('Propel\Tests\Bookstore\Map\BookTableMap::DEFAULT_STRING_FORMAT'), 'every Peer class has the DEFAULT_STRING_FORMAT constant');
+ $this->assertEquals('YAML', AuthorTableMap::DEFAULT_STRING_FORMAT, 'default string format is YAML by default');
+ $this->assertEquals('XML', PublisherTableMap::DEFAULT_STRING_FORMAT, 'default string format can be customized using the defaultStringFormat attribute in the schema');
}
}

0 comments on commit ec3f938

Please sign in to comment.