src/Entity/FaqAnswer.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\FaqAnswerRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * The field is the uri of the associated question
  10.  * The value is the answer content
  11.  * @ORM\Entity(repositoryClass=FaqAnswerRepository::class)
  12.  * @ApiResource(
  13.  *     denormalizationContext={
  14.  *          "groups"={"faq_answer:write"}
  15.  *     },
  16.  *     normalizationContext={
  17.  *          "groups"={"faq_answer:read"}
  18.  *     },
  19.  *     collectionOperations={
  20.  *              "post"={"security"="is_granted('ROLE_ADMIN')"},
  21.  *              "get"={"security"="is_granted('ROLE_USER')"},
  22.  *     },
  23.  *     itemOperations={
  24.  *              "get"={"security"="is_granted('ROLE_USER')"},
  25.  *              "delete"={"security"="is_granted('ROLE_ADMIN')"},
  26.  *              "patch"={"security"="is_granted('ROLE_ADMIN')"},
  27.  *     },
  28.  * )
  29.  */
  30. class FaqAnswer extends TvConfiguration
  31. {
  32.     /**
  33.      * @var string
  34.      * @Groups({"faq_answer:write","faq_answer:read"})
  35.      */
  36.     private $question;
  37.     /**
  38.      * @return int|string
  39.      */
  40.     public function getQuestion()
  41.     {
  42.         if ($this->question == null){
  43.             $this->question $this->field;
  44.         }
  45.         return $this->question;
  46.     }
  47.     /**
  48.      * @param int|string $question
  49.      * @return FaqAnswer
  50.      */
  51.     public function setQuestion(string $question) :FaqAnswer
  52.     {
  53.         $this->question $question;
  54.         $this->field $question;
  55.         return $this;
  56.     }
  57.     public function getField(): ?string
  58.     {
  59.         return $this->field;
  60.     }
  61.     public function setField(string $field): TvConfiguration
  62.     {
  63.         $this->field $field;
  64.         $this->question $field;
  65.         return $this;
  66.     }
  67.     public function getValue(): ?string
  68.     {
  69.         return $this->value;
  70.     }
  71.     public function setValue(string $value): TvConfiguration
  72.     {
  73.         $this->value $value;
  74.         $this->advice $value;
  75.         return $this;
  76.     }
  77. }