PersonalizedList.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Access;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use App\Repository\Access\PersonalizedListRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use JetBrains\PhpStorm\Pure;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12. * Liste personnalisées
  13. */
  14. #[ApiResource(
  15. operations: [
  16. new Get(
  17. security: 'object.getAccess().getId() == user.getId()'
  18. ),
  19. new GetCollection(
  20. normalizationContext: ['groups' => ['lists:output']]
  21. )
  22. ],
  23. paginationEnabled: false
  24. )]
  25. #[ORM\Entity(repositoryClass: PersonalizedListRepository::class)]
  26. class PersonalizedList
  27. {
  28. #[ORM\Id]
  29. #[ORM\Column]
  30. #[ORM\GeneratedValue]
  31. #[Groups(['lists:output'])]
  32. private ?int $id = null;
  33. #[ORM\ManyToOne(inversedBy: 'personalizedLists')]
  34. #[ORM\JoinColumn(nullable: false)]
  35. private ?Access $access = null;
  36. #[ORM\Column(length: 200, nullable: true)]
  37. #[Groups(['lists:output'])]
  38. private ?string $label = null;
  39. #[ORM\Column(length: 4294967295, nullable: true)]
  40. private ?array $filters = null;
  41. #[ORM\Column(length: 150)]
  42. #[Groups(['lists:output'])]
  43. private string $entity;
  44. #[ORM\Column(length: 4294967295, nullable: true)]
  45. private array $columns;
  46. #[ORM\Column(length: 150, nullable: true)]
  47. #[Groups(['lists:output'])]
  48. private string $menuKey;
  49. #[Pure]
  50. public function __construct()
  51. {
  52. }
  53. public function getId(): ?int
  54. {
  55. return $this->id;
  56. }
  57. public function setFilters(array $filters): self
  58. {
  59. $this->filters = $filters;
  60. return $this;
  61. }
  62. public function getFilters(): ?array
  63. {
  64. return $this->filters;
  65. }
  66. public function setColumns(array $columns): self
  67. {
  68. $this->columns = $columns;
  69. return $this;
  70. }
  71. public function getColumns(): ?array
  72. {
  73. return $this->columns;
  74. }
  75. public function setAccess(Access $access): self
  76. {
  77. $this->access = $access;
  78. return $this;
  79. }
  80. public function getAccess(): ?Access
  81. {
  82. return $this->access;
  83. }
  84. public function setMenuKey(string $menuKey): self
  85. {
  86. $this->menuKey = $menuKey;
  87. return $this;
  88. }
  89. public function getMenuKey(): ?string
  90. {
  91. return $this->menuKey;
  92. }
  93. public function setLabel(string $label): self
  94. {
  95. $this->label = $label;
  96. return $this;
  97. }
  98. public function getLabel(): ?string
  99. {
  100. return $this->label;
  101. }
  102. public function setEntity(string $entity): self
  103. {
  104. $this->entity = $entity;
  105. return $this;
  106. }
  107. public function getEntity(): ?string
  108. {
  109. return $this->entity;
  110. }
  111. }