Skip to content
Browse files

Added more templates

  • Loading branch information...
1 parent a07adf4 commit 73873db0ce42d39536fe6f21ed02207f4b744fd3 @willdurand willdurand committed
View
209 src/EqualNestParentBehaviorObjectBuilderModifier.php
@@ -25,11 +25,11 @@ class EqualNestParentBehaviorObjectBuilderModifier
public function __construct($behavior, $middleTable)
{
- $this->behavior = $behavior;
- $this->table = $behavior->getTable();
- $this->middleTable = $middleTable;
- $this->middleBehavior = $this->middleTable->getBehavior('equal_nest');
- }
+ $this->behavior = $behavior;
+ $this->table = $behavior->getTable();
+ $this->middleTable = $middleTable;
+ $this->middleBehavior = $this->middleTable->getBehavior('equal_nest');
+ }
public function objectAttributes($builder)
{
@@ -43,7 +43,7 @@ public function objectAttributes($builder)
), '/templates/parent/');
}
- public function objectMethods($builder)
+ public function objectMethods($builder)
{
$builder->declareClassFromBuilder($builder->getNewStubQueryBuilder($this->middleTable));
$builder->declareClassFromBuilder($builder->getNewStubPeerBuilder($this->middleTable));
@@ -73,10 +73,10 @@ public function objectMethods($builder)
return $script;
}
- public function postSave($builder)
- {
- return $this->behavior->renderTemplate('postSave', array(), '/templates/parent/');
- }
+ public function postSave($builder)
+ {
+ return $this->behavior->renderTemplate('postSave', array(), '/templates/parent/');
+ }
public function objectClearReferences($builder)
{
@@ -87,16 +87,16 @@ public function objectClearReferences($builder)
}
public function addPorcessEqualNestQueries($builder)
- {
- return $this->behavior->renderTemplate('processEqualNestQueries', array(
- 'collName' => $this->getEqualNestCollectionName($builder),
- 'listName' => $this->getEqualNestListPksName($builder),
- 'peerClassname' => $builder->getStubPeerBuilder()->getClassname(),
- 'refPeerClassname' => $builder->getNewStubPeerBuilder($this->behavior->getMiddleTable())->getClassname(),
- 'refTableName' => $this->middleTable->getPhpName(),
- 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
- ), '/templates/parent/');
- }
+ {
+ return $this->behavior->renderTemplate('processEqualNestQueries', array(
+ 'collName' => $this->getEqualNestCollectionName($builder),
+ 'listName' => $this->getEqualNestListPksName($builder),
+ 'peerClassname' => $builder->getStubPeerBuilder()->getClassname(),
+ 'refPeerClassname' => $builder->getNewStubPeerBuilder($this->behavior->getMiddleTable())->getClassname(),
+ 'refTableName' => $this->middleTable->getPhpName(),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ ), '/templates/parent/');
+ }
public function addClearListRelatedPKs($builder)
{
@@ -133,56 +133,22 @@ public function addClearRelatedCollection($builder)
), '/templates/parent/');
}
- public function addInitRelatedCollection($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- $peerClassname = $builder->getStubPeerBuilder()->getClassname();
- $objectClass = $builder->getStubObjectBuilder()->getFullyQualifiedClassname();
-
- $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 "
-/**
- * Initializes the $varRelatedObjectsColl collection.
- *
- * By default this just sets the $varRelatedObjectsColl collection to an empty PropelObjectCollection;
- * however, you may wish to override this method in your stub class to provide setting appropriate
- * to your application -- for example, setting the initial array to the values stored in database (ie, calling get$pluralRefTableName).
- *
- * @return void
- */
-protected function init$pluralRefTableName()
-{
- \$this->$varRelatedObjectsColl = new PropelObjectCollection();
- \$this->{$varRelatedObjectsColl}->setModel('{$objectClass}');
-}
-";
- }
-
- public function addRemoveAllRelations($builder)
- {
- $refTableName = $this->middleTable->getPhpName();
- $pluralRefTableName = $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
+ public function addInitRelatedCollection($builder)
+ {
+ return $this->behavior->renderTemplate('addInitRelatedCollection', array(
+ 'varRelatedObjectsColl' => $this->getEqualNestCollectionName($builder),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'objectClass' => $builder->getStubObjectBuilder()->getFullyQualifiedClassname(),
+ ), '/templates/parent/');
+ }
- return "
-/**
- * Removes all Equal Nest $pluralRefTableName relations
- *
- * @return void
- * @see add$refTableName()
- * @see set$pluralRefTableName()
- */
-public function remove$pluralRefTableName()
-{
- // this sets the collection to an empty Propel object collection; upon save, all relations will be removed
- self::init$pluralRefTableName();
-}
-";
- }
+ public function addRemoveAllRelations($builder)
+ {
+ return $this->behavior->renderTemplate('addRemoveAllRelations', array(
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'refTableName' => $this->middleTable->getPhpName(),
+ ), '/templates/parent/');
+ }
public function addGetRelatedCollection($builder)
{
@@ -337,46 +303,25 @@ public function add$refTableName({$objectClassname} \$a$refTableName)
";
}
- public function addObjectToRelatedCollection($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 "
-/**
- * Method called to associate multiple {$objectClassname} objects as Equal Nest $pluralRefTableName of this one
- *
- * @param {$objectClassname}[] $pluralRefTableName The {$objectClassname} objects to set as Equal Nest $pluralRefTableName relation of the current object
- * @return void
- * @throws PropelException
- */
-public function add$pluralRefTableName(\$$pluralRefTableName)
-{
- foreach (\$$pluralRefTableName as \$a$pluralRefTableName) {
- \$this->add$refTableName(\$a$pluralRefTableName);
- }
-}
-";
- }
+ public function addObjectToRelatedCollection($builder)
+ {
+ return $this->behavior->renderTemplate('addObjectToRelatedCollection', array(
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'refTableName' => $this->middleTable->getPhpName(),
+ ), '/templates/parent/');
+ }
- public function removeObjectFromRelatedCollection($builder)
- {
- return $this->behavior->renderTemplate('removeObjectFromRelatedCollection', array(
- 'refTableName' => $this->middleTable->getPhpName(),
- 'varRefTableName' => '$' . lcfirst($this->middleTable->getPhpName()),
- 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
- 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
- 'varRelObjectsColl' => $this->getEqualNestCollectionName($builder),
- ), '/templates/parent/');
- }
+ public function removeObjectFromRelatedCollection($builder)
+ {
+ return $this->behavior->renderTemplate('removeObjectFromRelatedCollection', array(
+ 'refTableName' => $this->middleTable->getPhpName(),
+ 'varRefTableName' => '$' . lcfirst($this->middleTable->getPhpName()),
+ 'pluralRefTableName' => $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()),
+ 'objectClassname' => $builder->getStubObjectBuilder()->getClassname(),
+ 'varRelObjectsColl' => $this->getEqualNestCollectionName($builder),
+ ), '/templates/parent/');
+ }
public function countObjectsInRelatedCollection($builder)
{
@@ -426,33 +371,33 @@ public function count$pluralRefTableName(Criteria \$criteria = null, \$distinct
";
}
- protected function getMiddleTable()
- {
- return $this->getTable()->getDatabase()->getTable($this->getParameter('extends'));
- }
+ protected function getMiddleTable()
+ {
+ return $this->getTable()->getDatabase()->getTable($this->getParameter('extends'));
+ }
- protected function getParameter($key)
- {
- return $this->behavior->getParameter($key);
- }
+ protected function getParameter($key)
+ {
+ return $this->behavior->getParameter($key);
+ }
- protected function getColumnAttribute($name)
- {
- return strtolower($this->behavior->getColumnForParameter($name)->getName());
- }
+ protected function getColumnAttribute($name)
+ {
+ return strtolower($this->behavior->getColumnForParameter($name)->getName());
+ }
- protected function getColumnPhpName($name)
- {
- return $this->behavior->getColumnForParameter($name)->getPhpName();
- }
+ protected function getColumnPhpName($name)
+ {
+ return $this->behavior->getColumnForParameter($name)->getPhpName();
+ }
- protected function getEqualNestCollectionName($builder)
- {
- return 'collEqualNest' . $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
- }
+ protected function getEqualNestCollectionName($builder)
+ {
+ return 'collEqualNest' . $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName());
+ }
- protected function getEqualNestListPksName($builder)
- {
- return sprintf('listEqualNest%sPKs', $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()));
- }
+ protected function getEqualNestListPksName($builder)
+ {
+ return sprintf('listEqualNest%sPKs', $builder->getPluralizer()->getPluralForm($this->middleTable->getPhpName()));
+ }
}
View
13 src/templates/parent/addInitRelatedCollection.php
@@ -0,0 +1,13 @@
+
+/**
+ * Initializes the <?php echo $varRelatedObjectsColl ?> collection.
+ *
+ * By default this just sets the <?php echo $varRelatedObjectsColl ?> collection to an empty PropelObjectCollection;
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database (ie, calling get<?php echo $pluralRefTableName ?>).
+ */
+protected function init<?php echo $pluralRefTableName ?>()
+{
+ $this-><?php echo $varRelatedObjectsColl ?> = new PropelObjectCollection();
+ $this-><?php echo $varRelatedObjectsColl ?>->setModel('<?php echo $objectClass ?>');
+}
View
14 src/templates/parent/addObjectToRelatedCollection.php
@@ -0,0 +1,14 @@
+
+/**
+ * Method called to associate multiple <?php echo $objectClassname ?> objects as Equal Nest <?php echo $pluralRefTableName ?> of this one
+ *
+ * @param <?php echo $objectClassname ?>[] <?php echo $pluralRefTableName ?> The <?php echo $objectClassname ?> objects to set as
+ * Equal Nest <?php echo $pluralRefTableName ?> relation of the current object.
+ * @throws PropelException
+ */
+public function add<?php echo $pluralRefTableName ?>(<?php echo '$' . $pluralRefTableName ?>)
+{
+ foreach (<?php echo '$' . $pluralRefTableName ?> as $a<?php echo $pluralRefTableName ?>) {
+ $this->add<?php echo $refTableName ?>($a<?php echo $pluralRefTableName ?>);
+ }
+}
View
12 src/templates/parent/addRemoveAllRelations.php
@@ -0,0 +1,12 @@
+
+/**
+ * Removes all Equal Nest <?php echo $pluralRefTableName ?> relations
+ *
+ * @see add<?php echo $refTableName ?>()
+ * @see set<?php echo $pluralRefTableName ?>()
+ */
+public function remove<?php echo $pluralRefTableName ?>()
+{
+ // this sets the collection to an empty Propel object collection; upon save, all relations will be removed
+ self::init<?php echo $pluralRefTableName ?>();
@VanTanev Owner
VanTanev added a note

$this instead of self?

agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+}

0 comments on commit 73873db

Please sign in to comment.
Something went wrong with that request. Please try again.