src/Entity/SurveyCompanyToken.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7.  * @ORM\Entity(repositoryClass=App\Repository\SurveyCompanyTokenRepository::class)
  8.  * @ORM\HasLifecycleCallbacks()
  9.  */
  10. #[ApiResource(
  11.     attributes: ['security' => "is_granted('ROLE_USER')"],
  12.     normalizationContext: ['groups' => ['surveyCompanyToken:read']],
  13.     denormalizationContext: ['groups' => ['surveyCompanyToken:write']],
  14.     collectionOperations: [
  15.         'get',
  16.         'post' => [
  17.             'security' => "is_granted('ROLE_ADMIN')",
  18.         ],
  19.     ],
  20.     itemOperations: [
  21.         'get',
  22.         'put' => ['security' => "is_granted('ROLE_ADMIN') or object.owner == user"],
  23.     ],
  24. )]
  25. class SurveyCompanyToken
  26. {
  27.     /**
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     public $id;
  33.     /**
  34.      * @var Token
  35.      *
  36.      * @ORM\ManyToOne(targetEntity=Token::class, inversedBy="surveyCompanyTokens")
  37.      * @ORM\JoinColumn(nullable=false)
  38.      * @Groups({"surveyCompanyToken:read", "surveyCompanyToken:write","surveyComapany:item", "surveyComapany:write","pinpointCampaign:list"})
  39.      */
  40.     public $token;
  41.     /**
  42.      * @var string
  43.      *
  44.      * @ORM\Column(type="string", length=128)
  45.      * @Groups({"surveyCompanyToken:read", "surveyCompanyToken:write","surveyComapany:item", "surveyComapany:write","pinpointCampaign:list"})
  46.      */
  47.     public $replaceValue;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity=SurveyCompany::class, inversedBy="surveyCompanyTokens")
  50.      * @ORM\JoinColumn(nullable=false)
  51.      * @Groups({"surveyCompanyToken:read", "surveyCompanyToken:write","surveyComapany:item", "surveyComapany:write"})
  52.      */
  53.     private $surveyCompany;
  54.     public function __construct()
  55.     {
  56.     }
  57.     public function __toString(): string
  58.     {
  59.         return ($this->getToken()) ? $this->getToken()->getName() : '';
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getToken(): ?Token
  66.     {
  67.         return $this->token;
  68.     }
  69.     public function setToken(?Token $token): self
  70.     {
  71.         $this->token $token;
  72.         return $this;
  73.     }
  74.     public function getReplaceValue(): ?string
  75.     {
  76.         return $this->replaceValue;
  77.     }
  78.     public function setReplaceValue(string $replaceValue): self
  79.     {
  80.         $this->replaceValue $replaceValue;
  81.         return $this;
  82.     }
  83.     public function getSurveyCompany(): ?SurveyCompany
  84.     {
  85.         return $this->surveyCompany;
  86.     }
  87.     public function setSurveyCompany(?SurveyCompany $surveyCompany): self
  88.     {
  89.         $this->surveyCompany $surveyCompany;
  90.         return $this;
  91.     }
  92. }