Browse files

Add more templates

  • Loading branch information...
1 parent f94b3d8 commit 754cbfea9e9b959230e9741c0c8d0d93d8de9577 @willdurand willdurand committed Jul 2, 2012
View
241 src/EqualNestParentBehaviorObjectBuilderModifier.php
@@ -60,7 +60,7 @@ public function objectMethods($builder)
$script .= $this->addRemoveAllRelations($builder);
$script .= $this->addGetRelatedCollection($builder);
- $script .= $this->addSetRelatedColelction($builder);
+ $script .= $this->addSetRelatedCollection($builder);
$script .= $this->hasObjectInRelatedCollection($builder);
$script .= $this->setObjectsOfRelatedCollection($builder);
@@ -150,158 +150,49 @@ public function addRemoveAllRelations($builder)
), '/templates/parent/');
}
- public function addGetRelatedCollection($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- $peerClassname = $builder->getStubPeerBuilder()->getClassname();
- $objectClassname = $builder->getStubObjectBuilder()->getClassname();
-
- $pk = $this->table->getPrimaryKey(); /** @var Column */ $pk = $pk[0];
-
- $varListRelatedPKs = "listEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}PKs";
- $varRelatedObjectsColl = "collEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}";
+ public function addGetRelatedCollection($builder)
+ {
+ $pks = $this->table->getPrimaryKey();
+ $pk = $pks[0];
- return "
-/**
- * Gets an array of {$objectClassname} objects which are Equal Nest $pluralRefTableName of this object.
- *
- * If the \$criteria is not null, it is used to always fetch the results from the database.
- * Otherwise the results are fetched from the database the first time, then cached.
- * Next time the same method is called without \$criteria, the cached collection is returned.
- * If this {$objectClassname} object is new, it will return an empty collection; the criteria is ignored on a new object.
- *
- * @param Criteria \$criteria
- * @param PropelPDO \$con
- * @return PropelObjectCollection {$objectClassname}[] List of Equal Nest $pluralRefTableName of this {$objectClassname}
- * @throws PropelException
- */
-public function get$pluralRefTableName(Criteria \$criteria = null, PropelPDO \$con = null)
-{
- if (null === \$this->$varListRelatedPKs) {
- \$this->initList{$pluralRefTableName}PKs(\$con);
- }
-
- if (null === \$this->$varRelatedObjectsColl || null !== \$criteria) {
- if (array() === \$this->$varListRelatedPKs && null === \$this->$varRelatedObjectsColl) {
- // return empty collection
- \$this->init$pluralRefTableName();
- } else {
- \$new_collection = {$builder->getStubQueryBuilder()->getClassname()}::create(null, \$criteria)
- ->addUsingAlias({$pk->getConstantName()}, \$this->$varListRelatedPKs, Criteria::IN)
- ->find(\$con);
- if (null !== \$criteria) {
- return \$new_collection;
- }
- \$this->$varRelatedObjectsColl = \$new_collection;
+ 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,
+ ), '/templates/parent/');
}
- }
-
- return \$this->$varRelatedObjectsColl;
-}
-";
- }
-
- public function addSetRelatedColelction($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- $peerClassname = $builder->getStubPeerBuilder()->getClassname();
- $refPeerClassname = $builder->getNewStubPeerBuilder($this->behavior->getMiddleTable())->getClassname();
- $objectClassname = $builder->getStubObjectBuilder()->getClassname();
-
- $pk = $this->table->getPrimaryKey(); /** @var Column */ $pk = $pk[0];
-
- $varListRelatedPKs = "listEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}PKs";
- $varRelatedObjectsColl = "collEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}";
- return "
-/**
- * Set an array of {$objectClassname} objects as $pluralRefTableName of the this object
- *
- * @param {$objectClassname}[] \$objects The {$objectClassname} objects to set as $pluralRefTableName of the current object
- * @return void
- * @throws PropelException
- * @see add$refTableName()
- */
-public function set$pluralRefTableName(\$objects)
-{
- \$this->clear$pluralRefTableName();
- foreach (\$objects as \$a$refTableName) {
- if (!\$a$refTableName instanceof {$objectClassname}) {
- throw new PropelException(sprintf('[Equal Nest] Cannot set object of type %s as $refTableName, expected {$objectClassname}', is_object(\$a$refTableName) ? get_class(\$a$refTableName) : gettype(\$a$refTableName)));
- } else {
- \$this->add$refTableName(\$a$refTableName);
+ public function addSetRelatedCollection($builder)
+ {
+ return $this->behavior->renderTemplate('addSetRelatedCollection', array(
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'refTableName' => $this->middleTable->getPhpName(),
+ ), '/templates/parent/');
}
- }
-}
-";
- }
-
- public function hasObjectInRelatedCollection($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- $peerClassname = $builder->getStubPeerBuilder()->getClassname();
- $refPeerClassname = $builder->getNewStubPeerBuilder($this->behavior->getMiddleTable())->getClassname();
- $objectClassname = $builder->getStubObjectBuilder()->getClassname();
-
- $pk = $this->table->getPrimaryKey(); /** @var Column */ $pk = $pk[0];
-
- $varListRelatedPKs = "listEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}PKs";
- $varRelatedObjectsColl = "collEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}";
-
- return "
-/**
- * Checks for Equal Nest relation
- *
- * @param {$objectClassname} \$a$refTableName The object to check for Equal Nest $refTableName relation to the current object
- * @return boolean
- */
-public function has$refTableName({$objectClassname} \$a$refTableName)
-{
- if (null === \$this->$varRelatedObjectsColl) {
- \$this->get$pluralRefTableName();
- }
- return \$a{$refTableName}->isNew() || \$this->isNew()
- ? in_array(\$a$refTableName, \$this->{$varRelatedObjectsColl}->getArrayCopy())
- : in_array(\$a{$refTableName}->getPrimaryKey(), \$this->{$varRelatedObjectsColl}->getPrimaryKeys());
-}
-";
- }
-
- public function setObjectsOfRelatedCollection($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- $peerClassname = $builder->getStubPeerBuilder()->getClassname();
- $refPeerClassname = $builder->getNewStubPeerBuilder($this->behavior->getMiddleTable())->getClassname();
- $objectClassname = $builder->getStubObjectBuilder()->getClassname();
-
- $pk = $this->table->getPrimaryKey(); /** @var Column */ $pk = $pk[0];
-
- $varListRelatedPKs = "listEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}PKs";
- $varRelatedObjectsColl = "collEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}";
+ public function hasObjectInRelatedCollection($builder)
+ {
+ return $this->behavior->renderTemplate('hasObjectInRelatedCollection', array(
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'refTableName' => $this->middleTable->getPhpName(),
+ 'varRelatedObjectsColl' => $this->getEqualNestCollectionName($builder),
+ ), '/templates/parent/');
+ }
- return "
-/**
- * Method called to associate another {$objectClassname} object as a $refTableName of this one
- * through the Equal Nest $pluralRefTableName relation.
- *
- * @param {$objectClassname} \$a$refTableName The {$objectClassname} object to set as Equal Nest $pluralRefTableName relation of the current object
- * @return void
- * @throws PropelException
- */
-public function add$refTableName({$objectClassname} \$a$refTableName)
-{
- if (!\$this->has$refTableName(\$a$refTableName)) {
- \$this->{$varRelatedObjectsColl}[] = \$a$refTableName;
- \$a{$refTableName}->add{$refTableName}(\$this);
- }
-}
-";
- }
+ public function setObjectsOfRelatedCollection($builder)
+ {
+ return $this->behavior->renderTemplate('setObjectsOfRelatedCollection', array(
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'refTableName' => $this->middleTable->getPhpName(),
+ 'varRelatedObjectsColl' => $this->getEqualNestCollectionName($builder),
+ ), '/templates/parent/');
+ }
public function addObjectToRelatedCollection($builder)
{
@@ -323,53 +214,19 @@ public function removeObjectFromRelatedCollection($builder)
), '/templates/parent/');
}
- public function countObjectsInRelatedCollection($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- $peerClassname = $builder->getStubPeerBuilder()->getClassname();
- $refPeerClassname = $builder->getNewStubPeerBuilder($this->behavior->getMiddleTable())->getClassname();
-
- $pk = $this->table->getPrimaryKey(); /** @var Column */ $pk = $pk[0];
-
- $varListRelatedPKs = "listEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}PKs";
- $varRelatedObjectsColl = "collEqualNest{$builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName())}";
+ public function countObjectsInRelatedCollection($builder)
+ {
+ $pks = $this->table->getPrimaryKey();
+ $pk = $pks[0];
- return "
-/**
- * Returns the number of Equal Nest $pluralRefTableName of this object.
- *
- * @param Criteria \$criteria
- * @param boolean \$distinct
- * @param PropelPDO \$con
- * @return integer Count of \$pluralRefTableName
- * @throws PropelException
- */
-public function count$pluralRefTableName(Criteria \$criteria = null, \$distinct = false, PropelPDO \$con = null)
-{
- if (null === \$this->$varListRelatedPKs) {
- \$this->initList{$pluralRefTableName}PKs(\$con);
- }
-
- if (null === \$this->$varRelatedObjectsColl || null !== \$criteria) {
- if (\$this->isNew() && null === \$this->$varRelatedObjectsColl) {
- return 0;
- } else {
- \$query = {$builder->getStubQueryBuilder()->getClassname()}::create(null, \$criteria);
- if (\$distinct) {
- \$query->distinct();
- }
-
- return \$query
- ->addUsingAlias({$pk->getConstantName()}, \$this->$varListRelatedPKs, Criteria::IN)
- ->count(\$con);
+ 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,
+ ), '/templates/parent/');
}
- } else {
- return count(\$this->$varRelatedObjectsColl);
- }
-}
-";
- }
protected function getMiddleTable()
{
View
128 src/EqualNestParentBehaviorQueryBuilderModifier.php
@@ -10,95 +10,47 @@
/**
* @author Ivan Plamenov Tanev aka Crafty_Shadow @ WEBWORLD.BG <vankata.t@gmail.com>
- * @package propel.generator.behavior.equal_nest
*/
class EqualNestParentBehaviorQueryBuilderModifier
{
- protected $behavior, $table, $builder, $objectClassname, $peerClassname;
-
- /** @var Table */
- protected $middle_table;
-
- public function __construct($behavior, $middle_table)
- {
- $this->behavior = $behavior;
- $this->table = $behavior->getTable();
- $this->middle_table = $middle_table;
- }
-
- protected function getParameter($key)
- {
- return $this->behavior->getParameter($key);
- }
-
- protected function getColumn($name)
- {
- return $this->behavior->getColumnForParameter($name);
- }
-
- protected function setBuilder($builder)
- {
- $this->builder = $builder;
- $this->objectClassname = $builder->getStubObjectBuilder()->getClassname();
- $this->queryClassname = $builder->getStubQueryBuilder()->getClassname();
- $this->peerClassname = $builder->getStubPeerBuilder()->getClassname();
- }
-
- public function queryMethods($builder)
- {
- $this->setBuilder($builder);
- $script = '';
-
- $this->addFindRelatedObjects($script);
- $this->addCountRelatedObjects($script);
-
- return $script;
- }
-
- public function addFindRelatedObjects(&$script)
- {
- $objectName = '$' . $this->table->getStudlyPhpName();
-
- $script .= "
-/**
- * Find equal nest {$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} of the supplied {$this->objectClassname} object
- *
- * @param {$this->objectClassname} $objectName
- * @param PropelPDO \$con
- * @return {$this->objectClassname}[]|PropelObjectCollection
- */
-public function find{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}Of({$this->objectClassname} $objectName, \$con = null)
-{
- \$obj = clone $objectName;
- \$obj->clearList{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs();
- \$obj->clear{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}();
-
- return \$obj->get{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}(\$this, \$con);
-}
-";
- }
-
- public function addCountRelatedObjects(&$script)
- {
- $objectName = '$' . $this->table->getStudlyPhpName();
-
- $script .= "
-/**
- * Count equal nest {$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} of the supplied {$this->objectClassname} object
- *
- * @param {$this->objectClassname} $objectName
- * @param PropelPDO \$con
- * @return integer
- */
-public function count{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}Of({$this->objectClassname} $objectName, \$con = null)
-{
- \$obj = clone $objectName;
- \$obj->clearList{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs();
- \$obj->clear{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}();
-
- return \$obj->count{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}(\$this, \$con);
-}
-";
- }
-
+ protected $behavior;
+
+ protected $table;
+
+ protected $middleTable;
+
+ public function __construct($behavior, $middleTable)
+ {
+ $this->behavior = $behavior;
+ $this->table = $behavior->getTable();
+ $this->middleTable = $middleTable;
+ }
+
+ public function queryMethods($builder)
+ {
+ $script = '';
+
+ $script .= $this->addFindRelatedObjects($builder);
+ $script .= $this->addCountRelatedObjects($builder);
+
+ return $script;
+ }
+
+ public function addFindRelatedObjects($builder)
+ {
+ return $this->behavior->renderTemplate('addFindRelatedObjects', array(
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'objectName' => '$' . $this->table->getStudlyPhpName(),
+ ), '/templates/parent/');
+ }
+
+ public function addCountRelatedObjects($builder)
+ {
+ return $this->behavior->renderTemplate('addCountRelatedObjects', array(
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'objectName' => '$' . $this->table->getStudlyPhpName(),
+ ), '/templates/parent/');
+ }
}
View
16 src/templates/parent/addCountRelatedObjects.php
@@ -0,0 +1,16 @@
+
+/**
+ * Count equal nest <?php echo $pluralRefTableName ?> of the supplied <?php echo $objectClassname ?> object
+ *
+ * @param <?php echo $objectClassname ?> <?php echo $objectName ?>
+ * @param PropelPDO $con
+ * @return integer
+ */
+public function count<?php echo $pluralRefTableName ?>Of(<?php echo $objectClassname ?> <?php echo $objectName ?>, $con = null)
+{
+ $obj = clone <?php echo $objectName ?>;
+ $obj->clearList<?php echo $pluralRefTableName ?>PKs();
+ $obj->clear<?php echo $pluralRefTableName ?>();
+
+ return $obj->count<?php echo $pluralRefTableName ?>($this, $con);
+}
View
16 src/templates/parent/addFindRelatedObjects.php
@@ -0,0 +1,16 @@
+
+/**
+ * Find equal nest <?php echo $pluralRefTableName; ?> of the supplied <?php echo $objectClassname ?> object
+ *
+ * @param <?php echo $objectClassname ?> <?php echo $objectName ?>
+ * @param PropelPDO $con
+ * @return <?php echo $objectClassname ?>[]|PropelObjectCollection
+ */
+public function find<?php echo $pluralRefTableName ?>Of(<?php echo $objectClassname ?> <?php echo $objectName ?>, $con = null)
+{
+ $obj = clone <?php echo $objectName ?>;
+ $obj->clearList<?php echo $pluralRefTableName ?>PKs();
+ $obj->clear<?php echo $pluralRefTableName ?>();
+
+ return $obj->get<?php echo $pluralRefTableName ?>($this, $con);
+}
View
39 src/templates/parent/addGetRelatedCollection.php
@@ -0,0 +1,39 @@
+
+/**
+ * Gets an array of <?php echo $objectClassname ?> objects which are Equal Nest <?php echo $pluralRefTableName ?> of this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this <?php echo $objectClassname ?> object is new, it will return an empty collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @return PropelObjectCollection <?php echo $objectClassname ?>[] List of Equal Nest <?php echo $pluralRefTableName ?> of this <?php echo $objectClassname ?>.
+ * @throws PropelException
+ */
+public function get<?php echo $pluralRefTableName ?>(Criteria $criteria = null, PropelPDO $con = null)
+{
+ if (null === $this-><?php echo $varListRelatedPKs ?>) {
+ $this->initList<?php echo $pluralRefTableName ?>PKs($con);
+ }
+
+ if (null === $this-><?php echo $varRelatedObjectsColl ?> || null !== $criteria) {
+ if (array() === $this-><?php echo $varListRelatedPKs ?> && null === $this-><?php echo $varRelatedObjectsColl ?>) {
+ // return empty collection
+ $this->init<?php echo $pluralRefTableName ?>();
+ } else {
+ $newCollection = <?php echo $queryClassname ?>::create(null, $criteria)
+ ->addUsingAlias(<?php echo $pk->getConstantName() ?>, $this-><?php echo $varListRelatedPKs ?>, Criteria::IN)
+ ->find($con);
+
+ if (null !== $criteria) {
+ return $newCollection;
+ }
+
+ $this-><?php echo $varRelatedObjectsColl ?> = $newCollection;
+ }
+ }
+
+ return $this-><?php echo $varRelatedObjectsColl ?>;
+}
View
22 src/templates/parent/addSetRelatedCollection.php
@@ -0,0 +1,22 @@
+
+/**
+ * Set an array of <?php echo $objectClassname ?> objects as <?php echo $pluralRefTableName ?> of the this object
+ *
+ * @param <?php echo $objectClassname ?>[] $objects The <?php echo $objectClassname ?> objects to set as <?php echo $pluralRefTableName ?> of the current object
+ * @throws PropelException
+ * @see add<?php echo $refTableName ?>()
+ */
+public function set<?php echo $pluralRefTableName ?>($objects)
+{
+ $this->clear<?php echo $pluralRefTableName ?>();
+ foreach ($objects as $a<?php echo $refTableName ?>) {
+ if (!$a<?php echo $refTableName ?> instanceof <?php echo $objectClassname ?>) {
+ throw new PropelException(sprintf(
+ '[Equal Nest] Cannot set object of type %s as <?php echo $refTableName ?>, expected <?php echo $objectClassname ?>',
+ is_object($a<?php echo $refTableName ?>) ? get_class($a<?php echo $refTableName ?>) : gettype($a<?php echo $refTableName ?>)
+ ));
+ }
+
+ $this->add<?php echo $refTableName ?>($a<?php echo $refTableName ?>);
+ }
+}
View
33 src/templates/parent/countObjectsInRelatedCollection.php
@@ -0,0 +1,33 @@
+
+/**
+ * Returns the number of Equal Nest <?php echo $pluralRefTableName ?> of this object.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return integer Count of <?php echo $pluralRefTableName ?>
+ * @throws PropelException
+ */
+public function count<?php echo $pluralRefTableName ?>(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+{
+ if (null === $this-><?php echo $varListRelatedPKs ?>) {
+ $this->initList<?php echo $pluralRefTableName ?>PKs($con);
+ }
+
+ if (null === $this-><?php echo $varRelatedObjectsColl ?> || null !== $criteria) {
+ if ($this->isNew() && null === $this-><?php echo $varRelatedObjectsColl ?>) {
+ return 0;
+ } else {
+ $query = <?php echo $queryClassname ?>::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->addUsingAlias(<?php echo $pk->getConstantName() ?>, $this-><?php echo $varListRelatedPKs ?>, Criteria::IN)
+ ->count($con);
+ }
+ } else {
+ return count($this-><?php echo $varRelatedObjectsColl ?>);
+ }
+}
View
17 src/templates/parent/hasObjectInRelatedCollection.php
@@ -0,0 +1,17 @@
+
+/**
+ * Checks for Equal Nest relation
+ *
+ * @param <?php echo $objectClassname ?> $a<?php echo $refTableName ?> The object to check for Equal Nest <?php echo $refTableName ?> relation to the current object
+ * @return boolean
+ */
+public function has<?php echo $refTableName ?>(<?php echo $objectClassname ?> $a<?php echo $refTableName ?>)
+{
+ if (null === $this-><?php echo $varRelatedObjectsColl ?>) {
+ $this->get<?php echo $pluralRefTableName ?>();
+ }
+
+ return $a<?php echo $refTableName ?>->isNew() || $this->isNew()
+ ? in_array($a<?php echo $refTableName ?>, $this-><?php echo $varRelatedObjectsColl ?>->getArrayCopy())
+ : in_array($a<?php echo $refTableName ?>->getPrimaryKey(), $this-><?php echo $varRelatedObjectsColl ?>->getPrimaryKeys());
+}
View
15 src/templates/parent/setObjectsOfRelatedCollection.php
@@ -0,0 +1,15 @@
+
+/**
+ * Method called to associate another <?php echo $objectClassname ?> object as a <?php echo $refTableName ?> of this one
+ * through the Equal Nest <?php echo $pluralRefTableName ?> relation.
+ *
+ * @param <?php echo $objectClassname ?> $a<?php echo $refTableName ?> The <?php echo $objectClassname ?> object to set as Equal Nest <?php echo $pluralRefTableName ?> relation of the current object
+ * @throws PropelException
+ */
+public function add<?php echo $refTableName ?>(<?php echo $objectClassname ?> $a<?php echo $refTableName ?>)
+{
+ if (!$this->has<?php echo $refTableName ?>($a<?php echo $refTableName ?>)) {
+ $this-><?php echo $varRelatedObjectsColl ?>[] = $a<?php echo $refTableName ?>;
+ $a<?php echo $refTableName ?>->add<?php echo $refTableName ?>($this);
+ }
+}

0 comments on commit 754cbfe

Please sign in to comment.