FederationStructure.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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: ['isFederation', '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(nullable: true)]
  53. #[Groups(['federation_structure_item_get'])]
  54. private ?string $description;
  55. #[ORM\Column(type: 'integer', nullable: true)]
  56. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  57. private ?int $imageId;
  58. #[ORM\Column(nullable: true)]
  59. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  60. private ?string $type;
  61. #[ORM\Column(options: ['default' => false])]
  62. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  63. private bool $isFederation = false;
  64. #[ORM\Column(nullable: true)]
  65. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  66. private ?string $website;
  67. /** @var mixed[] */
  68. #[ORM\Column(type: 'json')]
  69. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  70. private array $addresses = [];
  71. #[ORM\Column(nullable: true)]
  72. #[Groups(['federation_structure_item_get'])]
  73. private ?string $phone = null;
  74. #[ORM\Column(nullable: true)]
  75. #[Groups(['federation_structure_item_get'])]
  76. private ?string $mobilePhone;
  77. #[ORM\Column(nullable: true)]
  78. #[Groups(['federation_structure_item_get'])]
  79. private ?string $email;
  80. #[ORM\Column(nullable: true)]
  81. #[Groups(['federation_structure_item_get'])]
  82. private ?string $facebook;
  83. #[ORM\Column(nullable: true)]
  84. #[Groups(['federation_structure_item_get'])]
  85. private ?string $twitter;
  86. #[ORM\Column(nullable: true)]
  87. #[Groups(['federation_structure_item_get'])]
  88. private ?string $instagram;
  89. #[ORM\Column(nullable: true)]
  90. #[Groups(['federation_structure_item_get'])]
  91. private ?string $youtube;
  92. /** @var mixed[]|null */
  93. #[ORM\Column(type: 'json', nullable: true)]
  94. #[Groups(['federation_structure_item_get'])]
  95. private ?array $articles;
  96. /** @var list<string>|null */
  97. #[ORM\Column(type: 'simple_array', nullable: true)]
  98. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  99. private ?array $practices;
  100. #[ORM\Column(type: 'integer', nullable: true)]
  101. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  102. private ?int $parentId;
  103. #[ORM\Column(nullable: true)]
  104. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  105. private ?string $parentName;
  106. /** @var list<string> */
  107. #[ORM\Column(type: 'simple_array')]
  108. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  109. private array $parents;
  110. #[ORM\Column(options: ['default' => false])]
  111. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  112. private bool $portailVisibility = false;
  113. /** @var mixed[] */
  114. #[ORM\Column(type: 'json')]
  115. #[Groups(['federation_structure_item_get', 'federation_structure_collection_get'])]
  116. private array $sections;
  117. public function getId(): int
  118. {
  119. return $this->id;
  120. }
  121. public function setId(int $id): FederationStructure
  122. {
  123. $this->id = $id;
  124. return $this;
  125. }
  126. public function getName(): string
  127. {
  128. return $this->name;
  129. }
  130. public function setName(string $name): FederationStructure
  131. {
  132. $this->name = $name;
  133. return $this;
  134. }
  135. public function getLogoId(): ?int
  136. {
  137. return $this->logoId;
  138. }
  139. public function setLogoId(?int $logoId): FederationStructure
  140. {
  141. $this->logoId = $logoId;
  142. return $this;
  143. }
  144. public function getDescription(): ?string
  145. {
  146. return $this->description;
  147. }
  148. public function setDescription(?string $description): FederationStructure
  149. {
  150. $this->description = $description;
  151. return $this;
  152. }
  153. public function getImageId(): ?int
  154. {
  155. return $this->imageId;
  156. }
  157. public function setImageId(?int $imageId): FederationStructure
  158. {
  159. $this->imageId = $imageId;
  160. return $this;
  161. }
  162. public function getType(): ?string
  163. {
  164. return $this->type;
  165. }
  166. public function setType(?string $type): FederationStructure
  167. {
  168. $this->type = $type;
  169. return $this;
  170. }
  171. public function getIsFederation(): bool
  172. {
  173. return $this->isFederation;
  174. }
  175. public function setIsFederation(bool $isFederation): self
  176. {
  177. $this->isFederation = $isFederation;
  178. return $this;
  179. }
  180. public function getWebsite(): ?string
  181. {
  182. return $this->website;
  183. }
  184. public function setWebsite(?string $website): FederationStructure
  185. {
  186. $this->website = $website;
  187. return $this;
  188. }
  189. /**
  190. * @return mixed[]
  191. */
  192. public function getAddresses(): array
  193. {
  194. return $this->addresses;
  195. }
  196. /**
  197. * @param mixed[] $addresses
  198. */
  199. public function setAddresses(array $addresses): FederationStructure
  200. {
  201. $this->addresses = $addresses;
  202. return $this;
  203. }
  204. public function getPhone(): ?string
  205. {
  206. return $this->phone;
  207. }
  208. public function setPhone(?string $phone): FederationStructure
  209. {
  210. $this->phone = $phone;
  211. return $this;
  212. }
  213. public function getMobilePhone(): ?string
  214. {
  215. return $this->mobilePhone;
  216. }
  217. public function setMobilePhone(?string $mobilePhone): FederationStructure
  218. {
  219. $this->mobilePhone = $mobilePhone;
  220. return $this;
  221. }
  222. public function getEmail(): ?string
  223. {
  224. return $this->email;
  225. }
  226. public function setEmail(?string $email): self
  227. {
  228. $this->email = $email;
  229. return $this;
  230. }
  231. public function getFacebook(): ?string
  232. {
  233. return $this->facebook;
  234. }
  235. public function setFacebook(?string $facebook): self
  236. {
  237. $this->facebook = $facebook;
  238. return $this;
  239. }
  240. public function getTwitter(): ?string
  241. {
  242. return $this->twitter;
  243. }
  244. public function setTwitter(?string $twitter): self
  245. {
  246. $this->twitter = $twitter;
  247. return $this;
  248. }
  249. public function getInstagram(): ?string
  250. {
  251. return $this->instagram;
  252. }
  253. public function setInstagram(?string $instagram): self
  254. {
  255. $this->instagram = $instagram;
  256. return $this;
  257. }
  258. public function getYoutube(): ?string
  259. {
  260. return $this->youtube;
  261. }
  262. public function setYoutube(?string $youtube): FederationStructure
  263. {
  264. $this->youtube = $youtube;
  265. return $this;
  266. }
  267. /**
  268. * @return mixed[]|null
  269. */
  270. public function getArticles(): ?array
  271. {
  272. return $this->articles;
  273. }
  274. /**
  275. * @param mixed[]|null $articles
  276. */
  277. public function setArticles(?array $articles): FederationStructure
  278. {
  279. $this->articles = $articles;
  280. return $this;
  281. }
  282. /**
  283. * @return list<string>|null
  284. */
  285. public function getPractices(): ?array
  286. {
  287. return $this->practices;
  288. }
  289. /**
  290. * @param list<string>|null $practices
  291. */
  292. public function setPractices(?array $practices): FederationStructure
  293. {
  294. $this->practices = $practices;
  295. return $this;
  296. }
  297. public function getParentId(): ?int
  298. {
  299. return $this->parentId;
  300. }
  301. public function setParentId(?int $parentId): FederationStructure
  302. {
  303. $this->parentId = $parentId;
  304. return $this;
  305. }
  306. public function getParentName(): ?string
  307. {
  308. return $this->parentName;
  309. }
  310. public function setParentName(?string $parentName): FederationStructure
  311. {
  312. $this->parentName = $parentName;
  313. return $this;
  314. }
  315. /**
  316. * @return list<string>
  317. */
  318. public function getParents(): array
  319. {
  320. return $this->parents;
  321. }
  322. /**
  323. * @param list<string> $parents
  324. */
  325. public function setParents(array $parents): FederationStructure
  326. {
  327. $this->parents = $parents;
  328. return $this;
  329. }
  330. public function getPortailVisibility(): bool
  331. {
  332. return $this->portailVisibility;
  333. }
  334. public function setPortailVisibility(bool $portailVisibility): FederationStructure
  335. {
  336. $this->portailVisibility = $portailVisibility;
  337. return $this;
  338. }
  339. /**
  340. * @return mixed[]
  341. */
  342. public function getSections(): array
  343. {
  344. return $this->sections;
  345. }
  346. /**
  347. * @param mixed[] $sections
  348. */
  349. public function setSections(array $sections): FederationStructure
  350. {
  351. $this->sections = $sections;
  352. return $this;
  353. }
  354. }