Created
May 18, 2019 10:34
-
-
Save ismail1432/2b013344ab3dd0d9797d3e8259879584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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