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 #232 from adrienbrault/circular-references
Avoid serializing the same object twice
- Loading branch information
Showing
5 changed files
with
118 additions
and
3 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
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,31 @@ | ||
<?php | ||
|
||
namespace Hateoas\Tests\Fixtures; | ||
|
||
use Hateoas\Configuration\Annotation as Hateoas; | ||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
/** | ||
* @Serializer\ExclusionPolicy("all") | ||
* | ||
* @Hateoas\Relation("reference2", embedded="expr(object.getReference2())") | ||
*/ | ||
class CircularReference1 | ||
{ | ||
/** | ||
* @Serializer\Expose | ||
*/ | ||
private $name = 'reference1'; | ||
|
||
private $reference2; | ||
|
||
public function setReference2($reference2) | ||
{ | ||
$this->reference2 = $reference2; | ||
} | ||
|
||
public function getReference2() | ||
{ | ||
return $this->reference2; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Hateoas\Tests\Fixtures; | ||
|
||
use Hateoas\Configuration\Annotation as Hateoas; | ||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
/** | ||
* @Serializer\ExclusionPolicy("all") | ||
* | ||
* @Hateoas\Relation("reference1", embedded="expr(object.getReference1())") | ||
*/ | ||
class CircularReference2 | ||
{ | ||
/** | ||
* @Serializer\Expose | ||
*/ | ||
private $name = 'reference2'; | ||
|
||
private $reference1; | ||
|
||
public function setReference1($reference1) | ||
{ | ||
$this->reference1 = $reference1; | ||
} | ||
|
||
public function getReference1() | ||
{ | ||
return $this->reference1; | ||
} | ||
} |
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