Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Created May 18, 2019 10:34
Show Gist options
  • Save ismail1432/2b013344ab3dd0d9797d3e8259879584 to your computer and use it in GitHub Desktop.
Save ismail1432/2b013344ab3dd0d9797d3e8259879584 to your computer and use it in GitHub Desktop.
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Validator as CustomValidator;
/**
* @ORM\Entity(repositoryClass="App\Repository\PostRepository")
* @ApiResource(
* collectionOperations={"get", "post"},
* itemOperations={"get", "put"}
* )
*/
class Post
{
// Other properties
/**
* @ORM\Column(type="string", length=255)
*
* Apply our constraint and pass the allowed Role
* @CustomValidator\Role(role="ROLE_ADMIN")
*
*/
private $title;
// Setters and Getters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment