-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #982 from supersmile2009/bugfix/discriminator-base…
…-class-v1 Discriminator property serialization when parent is in discriminator map for v1
- Loading branch information
Showing
18 changed files
with
214 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace JMS\Serializer\Tests\Fixtures\Discriminator; | ||
|
||
class ImagePost extends Post | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace JMS\Serializer\Tests\Fixtures\Discriminator; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
/** | ||
* @Serializer\Discriminator(field = "type", map = { | ||
* "post": "JMS\Serializer\Tests\Fixtures\Discriminator\Post", | ||
* "image_post": "JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost", | ||
* }) | ||
*/ | ||
class Post | ||
{ | ||
/** @Serializer\Type("string") */ | ||
public $title; | ||
|
||
public function __construct($title) | ||
{ | ||
$this->title = $title; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
use JMS\Serializer\Metadata\ClassMetadata; | ||
|
||
$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost'); | ||
|
||
return $metadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
use JMS\Serializer\Metadata\ClassMetadata; | ||
use JMS\Serializer\Metadata\PropertyMetadata; | ||
|
||
$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\Post'); | ||
$metadata->setDiscriminator('type', array( | ||
'post' => 'JMS\Serializer\Tests\Fixtures\Discriminator\Post', | ||
'image_post' => 'JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost', | ||
)); | ||
|
||
$title = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\Post', 'title'); | ||
$title->setType('string'); | ||
$metadata->addPropertyMetadata($title); | ||
|
||
return $metadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<serializer> | ||
<class name="JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost"> | ||
</class> | ||
</serializer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<serializer> | ||
<class name="JMS\Serializer\Tests\Fixtures\Discriminator\Post" discriminator-field-name="type"> | ||
<discriminator-class value="post">JMS\Serializer\Tests\Fixtures\Discriminator\Post</discriminator-class> | ||
<discriminator-class value="image_post">JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost</discriminator-class> | ||
<property name="title" type="string" /> | ||
</class> | ||
</serializer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost: { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
JMS\Serializer\Tests\Fixtures\Discriminator\Post: | ||
discriminator: | ||
field_name: type | ||
map: | ||
post: JMS\Serializer\Tests\Fixtures\Discriminator\Post | ||
image_post: JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost | ||
|
||
properties: | ||
title: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<result> | ||
<type><![CDATA[image_post]]></type> | ||
<title><![CDATA[Image Post Title]]></title> | ||
</result> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<result> | ||
<title><![CDATA[Image Post Title]]></title> | ||
</result> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<result> | ||
<type><![CDATA[post]]></type> | ||
<title><![CDATA[Post Title]]></title> | ||
</result> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: image_post | ||
title: 'Image Post Title' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
title: 'Image Post Title' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: post | ||
title: 'Post Title' |