[PHP] Use parentSchema instead parent to detect inheritance

`parent` in a model is set not only when the model inherits from another
model but also when a parent container exists.

So We will now use `parentSchema` to check whether a parent class
exists. If si we still use `parent` to output the class name because
that has been converted to a proper model name and `parentSchema`
hasn't.
This commit is contained in:
Arne Jørgensen 2016-04-24 23:02:33 +02:00
parent 7f99469efd
commit bbe12c1658

View File

@ -46,7 +46,7 @@ use \ArrayAccess;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen * @link https://github.com/swagger-api/swagger-codegen
*/ */
class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayAccess class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}implements ArrayAccess
{ {
/** /**
* The original name of the model. * The original name of the model.
@ -64,7 +64,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
); );
static function swaggerTypes() { static function swaggerTypes() {
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}}; return self::$swaggerTypes{{#parentSchema}} + parent::swaggerTypes(){{/parentSchema}};
} }
/** /**
@ -77,7 +77,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
); );
static function attributeMap() { static function attributeMap() {
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap; return {{#parentSchema}}parent::attributeMap() + {{/parentSchema}}self::$attributeMap;
} }
/** /**
@ -90,7 +90,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
); );
static function setters() { static function setters() {
return {{#parent}}parent::setters() + {{/parent}}self::$setters; return {{#parentSchema}}parent::setters() + {{/parentSchema}}self::$setters;
} }
/** /**
@ -103,7 +103,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
); );
static function getters() { static function getters() {
return {{#parent}}parent::getters() + {{/parent}}self::$getters; return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters;
} }
{{#vars}} {{#vars}}
@ -120,7 +120,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
{{#parent}}parent::__construct($data);{{/parent}} {{#parentSchema}}parent::__construct($data);{{/parentSchema}}
{{#discriminator}}// Initialize discriminator property with the model name. {{#discriminator}}// Initialize discriminator property with the model name.
$discrimintor = array_search('{{discriminator}}', self::$attributeMap); $discrimintor = array_search('{{discriminator}}', self::$attributeMap);
$this->{$discrimintor} = static::$swaggerModelName; $this->{$discrimintor} = static::$swaggerModelName;