Author: ornicar2
Date: 2010-02-03 14:21:08 +0100 (Wed, 03 Feb 2010)
New Revision: 27492
Modified:
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmRecordLoremizer.php
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmTableLoremizer.php
Log:
[Diem]
- allowed to specify a record loremizer class in a table
- fixed possible infinite loop in table loremizer
Modified:
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmRecordLoremizer.php
===================================================================
---
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmRecordLoremizer.php
2010-02-03 13:06:34 UTC (rev 27491)
+++
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmRecordLoremizer.php
2010-02-03 13:21:08 UTC (rev 27492)
@@ -141,7 +141,7 @@
case 'clob':
if ($this->table->isMarkdownColumn($columnName))
{
- $val = dmLorem::getMarkdownLorem(1/*mt_rand(1, 3)*/);
+ $val = dmLorem::getMarkdownLorem(1);
}
else
{
Modified:
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmTableLoremizer.php
===================================================================
---
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmTableLoremizer.php
2010-02-03 13:06:34 UTC (rev 27491)
+++
plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/loremizer/dmTableLoremizer.php
2010-02-03 13:21:08 UTC (rev 27492)
@@ -35,8 +35,17 @@
}
$collection = new myDoctrineCollection($table);
+
+ if(method_exists($table, 'getRecordLoremizerClass'))
+ {
+ $recordLoremizerClass = $table->getRecordLoremizerClass();
+ }
+ else
+ {
+ $recordLoremizerClass = null;
+ }
- $loremizer = $this->serviceContainer->getService('record_loremizer')
+ $loremizer = $this->serviceContainer->getService('record_loremizer',
$recordLoremizerClass)
->setOption('create_associations', false);
for($it = $table->count(); $it < $this->getOption('nb_records'); $it++)
@@ -57,11 +66,11 @@
public function executeAssociations(dmDoctrineTable $table)
{
- $nbAssociations = $this->getOption('nb_records') * 2;
-
foreach($table->getRelationHolder()->getAssociations() as $association)
{
$refTable = $association->getAssociationTable();
+
+ $nbAssociations = $this->getOption('nb_records') * min(2,
$association->getTable()->count());
try
{
@@ -77,8 +86,16 @@
$collection = new myDoctrineCollection($refTable);
+ $iterations = 0;
+
while(count($createdPairs) < $nbAssociations)
{
+ // avoid infinite loop
+ if(++$iterations > 1000)
+ {
+ break;
+ }
+
$vals = array();
foreach($refTable->getRelationHolder()->getLocals() as $relationAlias
=> $relation)
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.