User Tools

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}}

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information