User Tools

Site Tools


symfony_apiplatform

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
symfony_apiplatform [2020/12/10 14:12] – created ssm2017symfony_apiplatform [2022/02/07 13:29] (current) – external edit 127.0.0.1
Line 44: Line 44:
         versions: [3]         versions: [3]
 </sxh> </sxh>
 +
 +==== disable operations ====
 +in entity class header
 +<sxh php>
 + * @ApiResource(
 +     collectionOperations={"get"},
 +     itemOperations={"get", "put", "delete"}
 + * )
 +</sxh>
 +
 +==== read/write properties ====
 +in entity class header
 +
 +  * normalisation = from server to client
 +  * denormalisation = from client to server
 +<sxh php>
 +/**
 + * @ApiResource(
 +     normalizationContext={"groups"={"article:read"}},
 +     denormalizationContext={"groups"={"article:write"}}
 + * )
 + * @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
 + */
 +class Article
 +{
 +    /**
 +     * @ORM\Id()
 +     * @ORM\GeneratedValue()
 +     * @ORM\Column(type="integer")
 +     *
 +     * @Groups("article:read")
 +     */
 +    private $id;
 +
 +    /**
 +     * @ORM\Column(type="string", length=255)
 +     *
 +     * @Groups({"article:read", "article:write"})
 +     */
 +    private $title;
 +</sxh>
 +
 +{{tag>symfony php}}
symfony_apiplatform.1607605956.txt.gz · Last modified: (external edit)