From 2ff1dcadc52c6123e0faeaa94da4ae239a6c7fb8 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Thu, 25 Oct 2007 21:01:29 +0000 Subject: [PATCH] Added better support for attributes generation in doctrine records --- lib/Doctrine/Import/Builder.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/Import/Builder.php b/lib/Doctrine/Import/Builder.php index b9c25c31a..67010106b 100644 --- a/lib/Doctrine/Import/Builder.php +++ b/lib/Doctrine/Import/Builder.php @@ -455,18 +455,24 @@ END; { $build = "\n"; foreach ($attributes as $key => $value) { - if ( ! is_array($value)) { - $value = array($value); - } + + if (is_bool($value)) + { + $values = $value ? 'true':'false'; + } else { + if ( ! is_array($value)) { + $value = array($value); + } - $values = ''; - foreach ($value as $attr) { - $values .= "Doctrine::" . strtoupper($key) . "_" . strtoupper($attr) . ' ^ '; + $values = ''; + foreach ($value as $attr) { + $values .= "Doctrine::" . strtoupper($key) . "_" . strtoupper($attr) . ' ^ '; + } + + // Trim last ^ + $values = substr($values, 0, strlen($values) - 3); } - // Trim last ^ - $values = substr($values, 0, strlen($values) - 3); - $build .= "\t\t\$this->setAttribute(Doctrine::ATTR_" . strtoupper($key) . ", " . $values . ");\n"; }