User Tools

Site Tools


symfony_apiplatform

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}}
symfony_apiplatform.1607606247.txt.gz · Last modified: (external edit)