Skip to content

Commit

Permalink
removed hack for generating temporal accessor comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Philip Scholten committed Oct 10, 2013
1 parent e1f9f06 commit b54bdbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 45 deletions.
44 changes: 0 additions & 44 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Expand Up @@ -381,50 +381,6 @@ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $c
";
}

/**
* Adds the comment for a temporal accessor.
*
* @param string &$script
* @param Column $column
*/
public function addTemporalAccessorComment(Column $column)
{
$script = '';
$clo = $column->getLowercasedName();

$dateTimeClass = $this->getBuildProperty('dateTimeClass');
if (!$dateTimeClass) {
$dateTimeClass = '\DateTime';
}

$handleMysqlDate = false;
if ($this->getPlatform() instanceof MysqlPlatform) {
if ($column->getType() === PropelTypes::TIMESTAMP) {
$handleMysqlDate = true;
$mysqlInvalidDateString = '0000-00-00 00:00:00';
} elseif ($column->getType() === PropelTypes::DATE) {
$handleMysqlDate = true;
$mysqlInvalidDateString = '0000-00-00';
}
// 00:00:00 is a valid time, so no need to check for that.
}

$script .= "
/**
* Get the [optionally formatted] temporal [$clo] column value.
* {$column->getDescription()}
*
* @param string \$format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw \DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" .($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '')."
*
* @throws PropelException - if unable to parse/validate the date/time value.
*/";

return $script;
}


/**
* Adds a tester method for an array column.
Expand Down
Expand Up @@ -10,7 +10,17 @@

{% embed 'Object/_accessor/_baseAccessor.php.twig' with {'builder': builder, 'column': column} %}
{% block comment %}
{{ builder.addTemporalAccessorComment(column) }} {# todo: remove this ugly hack #}
/**
* Get the [optionally formatted] temporal [{{ column.name|lower }}] column value.
* {{ column.description }}
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw \DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or {{ builder.buildProperty('dateTimeClass')|default('\DateTime') }} object (if format is NULL), NULL if column is NULL{% if builder.invalidTemporalString(column) is not null %}, and 0 if column value is {{ builder.invalidTemporalString(column) }}){% endif %}.
*
* @throws PropelException - if unable to parse/validate the date/time value.
*/
{% endblock %}
{% block parameters %}
{% set parameters = [{'name': 'format', 'default': defaultFormat|varExport, 'type': null}] %}
Expand Down

0 comments on commit b54bdbf

Please sign in to comment.