Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved constructor to template

  • Loading branch information...
commit d27023e031020e237031e6440c79be3c85a47924 1 parent b390499
@mpscholten authored
View
69 src/Propel/Generator/Builder/Om/ObjectBuilder.php
@@ -296,7 +296,6 @@ protected function addClassBody(&$script)
$script .= $this->twig->render('Object/_classBody.php.twig', ['builder' => $this]);
$table = $this->getTable();
- $this->addConstructor($script);
$this->addBaseObjectMethods($script);
@@ -406,74 +405,6 @@ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $c
}
/**
- * Adds the constructor for this object.
- *
- * @param string &$script
- */
- protected function addConstructor(&$script)
- {
- $this->addConstructorComment($script);
- $this->addConstructorOpen($script);
- if ($this->hasDefaultValues()) {
- $this->addConstructorBody($script);
- }
- $this->addConstructorClose($script);
- }
-
- /**
- * Adds the comment for the constructor
- *
- * @param string &$script
- */
- protected function addConstructorComment(&$script)
- {
- $script .= "
- /**
- * Initializes internal state of ".$this->getQualifiedClassName()." object.";
- if ($this->hasDefaultValues()) {
- $script .= "
- * @see applyDefaults()";
- }
- $script .= "
- */";
- }
-
- /**
- * Adds the function declaration for the constructor.
- *
- * @param string &$script
- */
- protected function addConstructorOpen(&$script)
- {
- $script .= "
- public function __construct()
- {";
- }
-
- /**
- * Adds the function body for the constructor.
- *
- * @param string &$script
- */
- protected function addConstructorBody(&$script)
- {
- $script .= "
- \$this->applyDefaultValues();";
- }
-
- /**
- * Adds the function close for the constructor.
- *
- * @param string &$script
- */
- protected function addConstructorClose(&$script)
- {
- $script .= "
- }
-";
- }
-
- /**
* Adds the base object functions.
*
* @param string &$script
View
4 src/Propel/Generator/Builder/Om/templates/Object/_classBody.php.twig
@@ -24,4 +24,6 @@
{% if builder.hasDefaultValues %}
{% include 'Object/_applyDefaultValues.php.twig' with {'builder': builder} %}
-{% endif %}
+{% endif %}
+
+{% include 'Object/_constructor.php.twig' with {'builder': builder} %}
View
12 src/Propel/Generator/Builder/Om/templates/Object/_constructor.php.twig
@@ -0,0 +1,12 @@
+/**
+ * Initializes internal state of {{ builder.qualifiedClassName }} object.
+{% if builder.defaultValues %}
+ * @see applyDefaults()"
+{% endif %}
+ */
+public function __construct()
+{
+ {% if builder.defaultValues %}
+ $this->applyDefaultValues();
+ {% endif %}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.