FederationStructure.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Public;
  4. use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
  5. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  6. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Metadata\ApiFilter;
  8. use ApiPlatform\Metadata\ApiResource;
  9. use ApiPlatform\Metadata\Get;
  10. use ApiPlatform\Metadata\GetCollection;
  11. use App\Filter\ApiPlatform\Utils\FindInSetFilter;
  12. use App\Repository\Public\FederationStructureRepository;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. /**
  16. * Structure telle qu'elle est représentée sur l'iframe de recherche des structures d'une fédération.
  17. *
  18. * Fichier source de la view : ./sql/schema-extensions/002-view_federation_structures.sql
  19. */
  20. #[ApiResource(
  21. operations: [
  22. new Get(
  23. uriTemplate: '/public/federation_structures/{id}',
  24. requirements: ['id' => '\\d+'],
  25. normalizationContext: ['groups' => ['federation_structure_item_get']]
  26. ),
  27. new GetCollection(
  28. uriTemplate: '/public/federation_structures',
  29. normalizationContext: ['groups' => ['federation_structure_collection_get']]
  30. ),
  31. ],
  32. paginationEnabled: false
  33. )]
  34. #[ORM\Entity(repositoryClass: FederationStructureRepository::class, readOnly: true)]
  35. #[ORM\Table(name: 'view_federation_structures')]
  36. #[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial', 'city' => 'exact'])]
  37. #[ApiFilter(filterClass: NumericFilter::class, properties: ['id', 'parentId'])]
  38. #[ApiFilter(filterClass: FindInSetFilter::class, properties: ['parents'])]
  39. #[ApiFilter(filterClass: BooleanFilter::class, properties: ['portailVisibility'])]
  40. class FederationStructure
  41. {
  42. #[ORM\Id]
  43. #[ORM\Column]
  44. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  45. private int $id;
  46. #[ORM\Column]
  47. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  48. private ?string $name;
  49. #[ORM\Column(type: 'integer', nullable: true)]
  50. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  51. private ?int $logoId;
  52. #[ORM\Column]
  53. #[Groups(['federation_structure_item_get'])]
  54. private ?string $description;
  55. #[ORM\Column(type: 'integer')]
  56. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  57. private ?int $imageId;
  58. #[ORM\Column]
  59. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  60. private ?string $type;
  61. #[ORM\Column(nullable: true)]
  62. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  63. private ?string $website;
  64. /** @var mixed[] */
  65. #[ORM\Column(type: 'json')]
  66. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  67. private array $addresses;
  68. #[ORM\Column]
  69. #[Groups(['federation_structure_item_get'])]
  70. private ?string $phone;
  71. #[ORM\Column]
  72. #[Groups(['federation_structure_item_get'])]
  73. private ?string $mobilePhone;
  74. #[ORM\Column]
  75. #[Groups(['federation_structure_item_get'])]
  76. private ?string $email;
  77. #[ORM\Column]
  78. #[Groups(['federation_structure_item_get'])]
  79. private ?string $facebook;
  80. #[ORM\Column]
  81. #[Groups(['federation_structure_item_get'])]
  82. private ?string $twitter;
  83. #[ORM\Column]
  84. #[Groups(['federation_structure_item_get'])]
  85. private ?string $instagram;
  86. #[ORM\Column]
  87. #[Groups(['federation_structure_item_get'])]
  88. private ?string $youtube;
  89. /** @var mixed[]|null */
  90. #[ORM\Column(type: 'json')]
  91. #[Groups(['federation_structure_item_get'])]
  92. private ?array $articles;
  93. /** @var list<string>|null */
  94. #[ORM\Column(type: 'simple_array')]
  95. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  96. private ?array $practices;
  97. #[ORM\Column(type: 'integer')]
  98. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  99. private ?int $parentId;
  100. #[ORM\Column]
  101. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  102. private ?string $parentName;
  103. /** @var list<string> */
  104. #[ORM\Column(type: 'simple_array')]
  105. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  106. private array $parents;
  107. #[ORM\Column(options: ['default' => false])]
  108. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  109. private bool $portailVisibility = false;
  110. public function getId(): int
  111. {
  112. return $this->id;
  113. }
  114. public function setId(int $id): FederationStructure
  115. {
  116. $this->id = $id;
  117. return $this;
  118. }
  119. public function getName(): string
  120. {
  121. return $this->name;
  122. }
  123. public function setName(string $name): FederationStructure
  124. {
  125. $this->name = $name;
  126. return $this;
  127. }
  128. public function getLogoId(): ?int
  129. {
  130. return $this->logoId;
  131. }
  132. public function setLogoId(?int $logoId): FederationStructure
  133. {
  134. $this->logoId = $logoId;
  135. return $this;
  136. }
  137. public function getDescription(): ?string
  138. {
  139. return $this->description;
  140. }
  141. public function setDescription(?string $description): FederationStructure
  142. {
  143. $this->description = $description;
  144. return $this;
  145. }
  146. public function getImageId(): ?int
  147. {
  148. return $this->imageId;
  149. }
  150. public function setImageId(?int $imageId): FederationStructure
  151. {
  152. $this->imageId = $imageId;
  153. return $this;
  154. }
  155. public function getType(): ?string
  156. {
  157. return $this->type;
  158. }
  159. public function setType(?string $type): FederationStructure
  160. {
  161. $this->type = $type;
  162. return $this;
  163. }
  164. public function getWebsite(): ?string
  165. {
  166. return $this->website;
  167. }
  168. public function setWebsite(?string $website): FederationStructure
  169. {
  170. $this->website = $website;
  171. return $this;
  172. }
  173. /**
  174. * @return mixed[]
  175. */
  176. public function getAddresses(): array
  177. {
  178. return $this->addresses;
  179. }
  180. /**
  181. * @param mixed[] $addresses
  182. */
  183. public function setAddresses(array $addresses): FederationStructure
  184. {
  185. $this->addresses = $addresses;
  186. return $this;
  187. }
  188. public function getPhone(): ?string
  189. {
  190. return $this->phone;
  191. }
  192. public function setPhone(?string $phone): FederationStructure
  193. {
  194. $this->phone = $phone;
  195. return $this;
  196. }
  197. public function getMobilePhone(): ?string
  198. {
  199. return $this->mobilePhone;
  200. }
  201. public function setMobilePhone(?string $mobilePhone): FederationStructure
  202. {
  203. $this->mobilePhone = $mobilePhone;
  204. return $this;
  205. }
  206. public function getEmail(): ?string
  207. {
  208. return $this->email;
  209. }
  210. public function setEmail(?string $email): self
  211. {
  212. $this->email = $email;
  213. return $this;
  214. }
  215. public function getFacebook(): ?string
  216. {
  217. return $this->facebook;
  218. }
  219. public function setFacebook(?string $facebook): self
  220. {
  221. $this->facebook = $facebook;
  222. return $this;
  223. }
  224. public function getTwitter(): ?string
  225. {
  226. return $this->twitter;
  227. }
  228. public function setTwitter(?string $twitter): self
  229. {
  230. $this->twitter = $twitter;
  231. return $this;
  232. }
  233. public function getInstagram(): ?string
  234. {
  235. return $this->instagram;
  236. }
  237. public function setInstagram(?string $instagram): self
  238. {
  239. $this->instagram = $instagram;
  240. return $this;
  241. }
  242. public function getYoutube(): ?string
  243. {
  244. return $this->youtube;
  245. }
  246. public function setYoutube(?string $youtube): FederationStructure
  247. {
  248. $this->youtube = $youtube;
  249. return $this;
  250. }
  251. /**
  252. * @return mixed[]|null
  253. */
  254. public function getArticles(): ?array
  255. {
  256. return $this->articles;
  257. }
  258. /**
  259. * @param mixed[]|null $articles
  260. */
  261. public function setArticles(?array $articles): FederationStructure
  262. {
  263. $this->articles = $articles;
  264. return $this;
  265. }
  266. /**
  267. * @return list<string>|null
  268. */
  269. public function getPractices(): ?array
  270. {
  271. return $this->practices;
  272. }
  273. /**
  274. * @param list<string>|null $practices
  275. */
  276. public function setPractices(?array $practices): FederationStructure
  277. {
  278. $this->practices = $practices;
  279. return $this;
  280. }
  281. public function getParentId(): ?int
  282. {
  283. return $this->parentId;
  284. }
  285. public function setParentId(?int $parentId): FederationStructure
  286. {
  287. $this->parentId = $parentId;
  288. return $this;
  289. }
  290. public function getParentName(): ?string
  291. {
  292. return $this->parentName;
  293. }
  294. public function setParentName(?string $parentName): FederationStructure
  295. {
  296. $this->parentName = $parentName;
  297. return $this;
  298. }
  299. /**
  300. * @return list<string>
  301. */
  302. public function getParents(): array
  303. {
  304. return $this->parents;
  305. }
  306. /**
  307. * @param list<string> $parents
  308. */
  309. public function setParents(array $parents): FederationStructure
  310. {
  311. $this->parents = $parents;
  312. return $this;
  313. }
  314. public function getPortailVisibility(): bool{
  315. return $this->portailVisibility;
  316. }
  317. public function setPortailVisibility(bool $portailVisibility) : FederationStructure{
  318. $this->portailVisibility = $portailVisibility;
  319. return $this;
  320. }
  321. }