Last active
March 20, 2018 21:57
-
-
Save bendavies/f1895a4089035d754b099d7b69a04c39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"_embedded": { | |
"parent": { | |
"_links": { | |
"self": { | |
"href": "/divisions/b76de4be-d59e-4562-b99c-78dafd04eef2" | |
} | |
}, | |
"id": "b76de4be-d59e-4562-b99c-78dafd04eef2", | |
"name": "Parent", | |
} | |
}, | |
"_links": { | |
"parent": { | |
"href": "/divisions/b76de4be-d59e-4562-b99c-78dafd04eef2" | |
}, | |
"self": { | |
"href": "/divisions/eb336846-faa9-49f2-b99c-dc811b0a2fbd" | |
} | |
}, | |
"id": "eb336846-faa9-49f2-b99c-dc811b0a2fbd", | |
"name": "Child" | |
} |
This file contains hidden or 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
{ | |
"_links": { | |
"parent": { | |
"href": "/divisions/b76de4be-d59e-4562-b99c-78dafd04eef2" | |
}, | |
"self": { | |
"href": "/divisions/eb336846-faa9-49f2-b99c-dc811b0a2fbd" | |
} | |
}, | |
"id": "eb336846-faa9-49f2-b99c-dc811b0a2fbd", | |
"name": "Child" | |
} |
This file contains hidden or 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
<?php | |
declare(strict_types=1); | |
namespace App\Entity; | |
use ApiPlatform\Core\Annotation\ApiProperty; | |
use ApiPlatform\Core\Annotation\ApiResource; | |
use Doctrine\ORM\Mapping as ORM; | |
use Ramsey\Uuid\Uuid; | |
use Symfony\Component\Serializer\Annotation\Groups; | |
/** | |
* @ApiResource( | |
* collectionOperations={ | |
* "get" = {"method" = "GET", "path" = "/divisions/", "normalization_context" = {"groups" = {"division"}}} | |
* }, | |
* itemOperations={ | |
* "get" = {"method" = "GET", "path" = "/divisions/{id}", "requirements" = {"id" = "%uuid_regex%"}, "normalization_context" = {"groups" = {"division"}}} | |
* } | |
* ) | |
* @ORM\Entity | |
*/ | |
class Division | |
{ | |
/** | |
* @var Uuid | |
* | |
* @Groups("division") | |
* | |
* @ORM\Id | |
* @ORM\Column(type="guid") | |
* @ORM\GeneratedValue(strategy="NONE") | |
*/ | |
protected $id; | |
/** | |
* @var string | |
* | |
* @Groups("division") | |
* | |
* @ORM\Column(type="string") | |
*/ | |
protected $name; | |
/** | |
* @var Division | |
* | |
* @ApiProperty(readableLink=false) | |
* @Groups("division") | |
* | |
* @ORM\ManyToOne(targetEntity="App\Entity\Division", inversedBy="children") | |
*/ | |
private $parent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment