From 6ca34e362def122e10d858e4c462508a987f21b2 Mon Sep 17 00:00:00 2001 From: James Ebentier Date: Fri, 13 Mar 2015 09:21:13 -0700 Subject: [PATCH 1/3] PHP Models: updating the models generated for PHP to be array accessable and have a simple constructor --- .../src/main/resources/php/model.mustache | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache index 13a9356d586..6de69cbafdd 100644 --- a/modules/swagger-codegen/src/main/resources/php/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model.mustache @@ -24,7 +24,7 @@ {{#models}} {{#model}} -class {{classname}} { +class {{classname}} implements ArrayAccess { static $swaggerTypes = array( {{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}}, {{/hasMore}}{{/vars}} @@ -35,6 +35,26 @@ class {{classname}} { * {{{description}}} */{{/description}} public ${{name}}; /* {{{datatype}}} */{{/vars}} + + public function __construct(array $data) { + {{#vars}}$this->{{name}} = $data["{{name}}"]{{/vars}} + } + + public function offsetExists($offset) { + return isset($this->$offset); + } + + public function offsetGet($offset) { + return $this->$offset; + } + + public function offsetSet($offset, $value) { + $this->$offset = $value; + } + + public function offsetUnset($offset) { + unset($this->$offset); + } } {{/model}} {{/models}} From 0854ca5ce53b159d92f1672d53a100a8c15e080d Mon Sep 17 00:00:00 2001 From: James Ebentier Date: Fri, 13 Mar 2015 09:23:55 -0700 Subject: [PATCH 2/3] PHP Models: updating the models generated for PHP styling --- modules/swagger-codegen/src/main/resources/php/model.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache index 6de69cbafdd..606203f8940 100644 --- a/modules/swagger-codegen/src/main/resources/php/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model.mustache @@ -37,7 +37,8 @@ class {{classname}} implements ArrayAccess { public ${{name}}; /* {{{datatype}}} */{{/vars}} public function __construct(array $data) { - {{#vars}}$this->{{name}} = $data["{{name}}"]{{/vars}} + {{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}, + {{/hasMore}}{{/vars}} } public function offsetExists($offset) { From 24842d4a29213efe9b7f49c2581f546af7a252ef Mon Sep 17 00:00:00 2001 From: James Ebentier Date: Fri, 13 Mar 2015 09:36:24 -0700 Subject: [PATCH 3/3] PHP Models: fixing an issue with commas being where they shouldn't --- modules/swagger-codegen/src/main/resources/php/model.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache index 606203f8940..f11a1547169 100644 --- a/modules/swagger-codegen/src/main/resources/php/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model.mustache @@ -37,7 +37,7 @@ class {{classname}} implements ArrayAccess { public ${{name}}; /* {{{datatype}}} */{{/vars}} public function __construct(array $data) { - {{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}, + {{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}} {{/hasMore}}{{/vars}} }