Permalink
Browse files

Refactor code to get the first primary key

  • Loading branch information...
1 parent bdc9ff6 commit a073d426309837aec6b511486105de6c129309f6 @willdurand willdurand committed Jul 2, 2012
@@ -108,15 +108,13 @@ public function addClearListRelatedPKs($builder)
public function addInitListRelatedPKs($builder)
{
- $pk = current($this->table->getPrimaryKey());
-
return $this->behavior->renderTemplate('addInitListRelatedPKs', array(
'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
'peerClassname' => $builder->getStubPeerBuilder()->getClassname(),
'varListRelatedPKs' => $this->getEqualNestListPksName($builder),
- 'pkName' => $pk->getStudlyPhpName(),
- 'tablePk' => $pk->getFullyQualifiedName(),
+ 'pkName' => $this->behavior->getFirstPrimaryKey()->getStudlyPhpName(),
+ 'tablePk' => $this->behavior->getFirstPrimaryKey()->getFullyQualifiedName(),
'tableName' => $this->table->getName(),
'middleTableName' => $this->middleTable->getName(),
'refColumn1' => $this->middleBehavior->getReferenceColumn1()->getFullyQualifiedName(),
@@ -152,16 +150,13 @@ public function addRemoveAllRelations($builder)
public function addGetRelatedCollection($builder)
{
- $pks = $this->table->getPrimaryKey();
- $pk = $pks[0];
-
return $this->behavior->renderTemplate('addGetRelatedCollection', array(
'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
'queryClassname' => $builder->getStubQueryBuilder()->getClassname(),
'varListRelatedPKs' => $this->getEqualNestListPksName($builder),
'varRelatedObjectsColl' => $this->getEqualNestCollectionName($builder),
- 'pk' => $pk,
+ 'pk' => $this->behavior->getFirstPrimaryKey(),
), '/templates/parent/');
}
@@ -216,15 +211,12 @@ public function removeObjectFromRelatedCollection($builder)
public function countObjectsInRelatedCollection($builder)
{
- $pks = $this->table->getPrimaryKey();
- $pk = $pks[0];
-
return $this->behavior->renderTemplate('countObjectsInRelatedCollection', array(
'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
'varListRelatedPKs' => $this->getEqualNestListPksName($builder),
'varRelatedObjectsColl' => $this->getEqualNestCollectionName($builder),
'queryClassname' => $builder->getStubQueryBuilder()->getClassname(),
- 'pk' => $pk,
+ 'pk' => $this->behavior->getFirstPrimaryKey(),
), '/templates/parent/');
}
@@ -51,7 +51,6 @@ public function addCountRelatedObjects($builder)
'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
'objectName' => '$' . $this->table->getStudlyPhpName(),
- 'pk' => $this->behavior->getFirstPrimaryKey(),
), '/templates/parent/');
}
}

0 comments on commit a073d42

Please sign in to comment.