Skip to content

Commit

Permalink
Moved constructor to template
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Philip Scholten committed Oct 4, 2013
1 parent b390499 commit d27023e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 70 deletions.
69 changes: 0 additions & 69 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ protected function addClassBody(&$script)
$script .= $this->twig->render('Object/_classBody.php.twig', ['builder' => $this]); $script .= $this->twig->render('Object/_classBody.php.twig', ['builder' => $this]);


$table = $this->getTable(); $table = $this->getTable();
$this->addConstructor($script);


$this->addBaseObjectMethods($script); $this->addBaseObjectMethods($script);


Expand Down Expand Up @@ -405,74 +404,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. * Adds the base object functions.
* *
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@


{% if builder.hasDefaultValues %} {% if builder.hasDefaultValues %}
{% include 'Object/_applyDefaultValues.php.twig' with {'builder': builder} %} {% include 'Object/_applyDefaultValues.php.twig' with {'builder': builder} %}
{% endif %} {% endif %}

{% include 'Object/_constructor.php.twig' with {'builder': builder} %}
Original file line number Original file line Diff line number Diff line change
@@ -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 %}
}

0 comments on commit d27023e

Please sign in to comment.