From addcf72ae62611205c793027a93e34af2aea24e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 8 Sep 2021 18:37:30 +0200 Subject: [PATCH] improve addresses --- src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php | 4 ++-- src/Bundle/ChillMainBundle/Entity/Address.php | 10 ++++++++++ .../Repository/AddressReferenceRepository.php | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php index 086b566da..0a0c160cd 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php @@ -21,7 +21,7 @@ class PointType extends Type { * * @param array $fieldDeclaration * @param AbstractPlatform $platform - * @return type + * @return string */ public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { @@ -32,7 +32,7 @@ class PointType extends Type { * * @param type $value * @param AbstractPlatform $platform - * @return Point + * @return ?Point */ public function convertToPHPValue($value, AbstractPlatform $platform) { diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index f3973ff0f..22e4848bf 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -383,6 +383,16 @@ class Address ; } + public static function createFromAddressReference(AddressReference $original): Address + { + return (new Address()) + ->setPoint($original->getPoint()) + ->setPostcode($original->getPostcode()) + ->setStreet($original->getStreet()) + ->setStreetNumber($original->getStreetNumber()) + ; + } + public function getStreet(): ?string { return $this->street; diff --git a/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php b/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php index f040446b3..cf488f411 100644 --- a/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php @@ -36,6 +36,14 @@ final class AddressReferenceRepository implements ObjectRepository return $this->repository->findAll(); } + public function countAll(): int + { + $qb = $this->repository->createQueryBuilder('ar'); + $qb->select('count(ar.id)'); + + return $qb->getQuery()->getSingleScalarResult(); + } + /** * @return AddressReference[] */