Permalink
Browse files

moved clear

  • Loading branch information...
mpscholten committed Oct 10, 2013
1 parent 317d220 commit bfba5e976d24f389d42f95c4ccea2ac738c833bd
@@ -321,12 +321,9 @@ protected function addClassBody(&$script)
$script .= $this->twig->render('Object/_classBody.php.twig', ['builder' => $this]);
- $table = $this->getTable();
-
$this->addRefFKMethods($script);
$this->addCrossFKMethods($script);
- $this->addClear($script);
$this->addClearAllReferences($script);
// apply behaviors
@@ -387,19 +384,6 @@ protected function addHasArrayElement(&$script, Column $column)
";
}
- /**
- * Adds the lazy loader method.
- *
- * @param string &$script
- * @param Column $column
- */
- protected function addLazyLoader(&$script, Column $column)
- {
- $this->addLazyLoaderBody($script, $column);
- $this->addLazyLoaderClose($script);
- }
-
-
/**
* Adds the function body for the lazy loader method.
*
@@ -2264,54 +2248,6 @@ protected function doUpdate(ConnectionInterface \$con)
";
}
- /**
- * Adds clear method
- * @param string &$script The script will be modified in this method.
- */
- protected function addClear(&$script)
- {
- $table = $this->getTable();
-
- $script .= "
- /**
- * Clears the current object and sets all attributes to their default values
- */
- public function clear()
- {";
- foreach ($table->getColumns() as $col) {
- $clo = $col->getLowercasedName();
- $script .= "
- \$this->".$clo." = null;";
- if ($col->isLazyLoad()) {
- $script .= "
- \$this->".$clo."_isLoaded = false;";
- }
- if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) {
- $cloUnserialized = $clo.'_unserialized';
-
- $script .="
- \$this->$cloUnserialized = null;";
- }
- }
-
- $script .= "
- \$this->alreadyInSave = false;
- \$this->clearAllReferences();";
-
- if ($this->hasDefaultValues()) {
- $script .= "
- \$this->applyDefaultValues();";
- }
-
- $script .= "
- \$this->resetModified();
- \$this->setNew(true);
- \$this->setDeleted(false);
- }
-";
- }
-
-
/**
* Adds clearAllReferencers() method which resets all the collections of referencing
* fk objects.
@@ -65,6 +65,7 @@
{% include 'Object/_copy.php.twig' with {'builder': builder} %}
{% include 'Object/_hydrate.php.twig' with {'builder': builder} %}
+ {% include 'Object/_clear.php.twig' with {'builder': builder} %}
{% include 'Object/_foreignKey/_methods.php.twig' with {'builder': builder} %}
@@ -0,0 +1,26 @@
+/**
+ * Clears the current object and sets all attributes to their default values
+ */
+public function clear()
+{
+ {% for column in builder.table.columns %}
+ $this->{{ column.name|lower }} = null;
+
+ {% if column.lazyLoad %}
+ $this->{{ column.name|lower }}_isLoaded = false;
+ {% endif %}
+ {% if column.phpArrayType or column.phpObjectType %}
+ $this->{{ column.name|lower }}_unserialized = null;
+ {% endif %}
+ {% endfor %}
+
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+
+ {% if builder.hasDefaultValues %}
+ $this->applyDefaultValues();
+ {% endif %}
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+}

0 comments on commit bfba5e9

Please sign in to comment.