From f48c80af1c2216f7f5f5184db9bee0e4104ea2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Wed, 11 Dec 2024 21:19:17 +0100 Subject: [PATCH] Add Building entity --- .gitignore | 4 ++ config/packages/api_platform.yaml | 4 +- src/Entity/Building.php | 57 +++++++++++++++++++++++++++ src/Repository/BuildingRepository.php | 43 ++++++++++++++++++++ 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 src/Entity/Building.php create mode 100644 src/Repository/BuildingRepository.php diff --git a/.gitignore b/.gitignore index a67f91e..21a196a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +.ddev +*.sql* +*.swp +*.swo ###> symfony/framework-bundle ### /.env.local diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml index 02f295a..3cab672 100644 --- a/config/packages/api_platform.yaml +++ b/config/packages/api_platform.yaml @@ -1,6 +1,6 @@ api_platform: - title: Hello API Platform - version: 1.0.0 + title: Architetture Roma - API + version: beta defaults: stateless: true cache_headers: diff --git a/src/Entity/Building.php b/src/Entity/Building.php new file mode 100644 index 0000000..09ed468 --- /dev/null +++ b/src/Entity/Building.php @@ -0,0 +1,57 @@ + 'building:item']), + new GetCollection(normalizationContext: ['groups' => 'building:list']) + ], + order: ['name' => 'DESC'], + paginationEnabled: false, +)] +class Building +{ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column] + #[Groups(['building:list', 'building:item'])] + private ?int $id = null; + + #[ORM\Column(length: 255, name: 'denominazione')] + #[Groups(['building:list', 'building:item'])] + private ?string $name = null; + + public function getId(): ?int + { + return $this->id; + } + + public function setId(int $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } +} diff --git a/src/Repository/BuildingRepository.php b/src/Repository/BuildingRepository.php new file mode 100644 index 0000000..eaaa4a5 --- /dev/null +++ b/src/Repository/BuildingRepository.php @@ -0,0 +1,43 @@ + + */ +class BuildingRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Building::class); + } + + // /** + // * @return Building[] Returns an array of Building objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('b') + // ->andWhere('b.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('b.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Building + // { + // return $this->createQueryBuilder('b') + // ->andWhere('b.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}