src/Entity/SurveyFormSurveyCompany.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  8. use App\Repository\SurveyFormSurveyCompanyRepository;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. /**
  13.  * @ORM\Entity(repositoryClass=SurveyFormSurveyCompanyRepository::class)
  14.  */
  15. #[HasLifecycleCallbacks()]
  16. #[ApiResource(
  17.     attributes: ['security' => "is_granted('ROLE_USER')"],
  18.     normalizationContext: ['groups' => ['sfsc:read']],
  19.     denormalizationContext: ['groups' => ['sfsc:write']],
  20.     collectionOperations: [
  21.         'get',
  22.         'post' => [
  23.             'security' => "is_granted('ROLE_ADMIN')",
  24.         ],
  25.     ],
  26.     itemOperations: [
  27.         'get',
  28.         'put' => ['security' => "is_granted('ROLE_ADMIN') or object.owner == user"],
  29.     ],
  30. )]
  31. #[ApiFilter(SearchFilter::class, properties: ['id''surveyCompany' => 'exact''surveyForm' => 'exact'])]
  32. #[ApiFilter(PropertyFilter::class)]
  33. #[ApiFilter(OrderFilter::class, properties: ['id''surveyCompany.title''surveyForm.title'], arguments: ['orderParameterName' => 'order'])]
  34. class SurveyFormSurveyCompany
  35. {
  36.     /**
  37.      * @ORM\Id
  38.      * @ORM\GeneratedValue
  39.      * @ORM\Column(type="integer")
  40.      */
  41.     private $id;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity=SurveyForm::class, inversedBy="surveyCompanies")
  44.      * @ORM\JoinColumn(name="survey_form_id", referencedColumnName="id", nullable=false)
  45.      * @Groups({"sfsc:read","sfsc:write"})
  46.      */
  47.     private $surveyForm;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity=SurveyCompany::class, inversedBy="forms")
  50.      * @ORM\JoinColumn(name="survey_company_id", referencedColumnName="id", nullable=false)
  51.      * @Groups({"sfsc:read","sfsc:write"})
  52.      */
  53.     private $surveyCompany;
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getSurveyForm(): ?SurveyForm
  59.     {
  60.         return $this->surveyForm;
  61.     }
  62.     public function setSurveyForm(?SurveyForm $surveyForm): self
  63.     {
  64.         $this->surveyForm $surveyForm;
  65.         return $this;
  66.     }
  67.     public function getSurveyCompany(): ?SurveyCompany
  68.     {
  69.         return $this->surveyCompany;
  70.     }
  71.     public function setSurveyCompany(?SurveyCompany $surveyCompany): self
  72.     {
  73.         $this->surveyCompany $surveyCompany;
  74.         return $this;
  75.     }
  76. }