User Tools

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
symfony_apiplatform [2020/12/10 14:17] ssm2017symfony_apiplatform [2022/02/07 13:29] (current) – external edit 127.0.0.1
Line 45: Line 45:
 </sxh> </sxh>
  
-{{tag>symfony}}+==== 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