diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php b/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php index b2be09645..b6c6106f1 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php @@ -15,10 +15,16 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Rename residential_address table + * Rename residential_address table. */ final class Version20220217133607 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE IF EXISTS chill_person_residential_address RENAME TO chill_main_residential_address;'); + $this->addSql('ALTER SEQUENCE IF EXISTS chill_person_residential_address_id_seq RENAME TO chill_main_residential_address_id_seq;'); + } + public function getDescription(): string { return 'Rename residential_address table'; @@ -29,10 +35,4 @@ final class Version20220217133607 extends AbstractMigration $this->addSql('ALTER TABLE IF EXISTS chill_main_residential_address RENAME TO chill_person_residential_address;'); $this->addSql('ALTER SEQUENCE IF EXISTS chill_main_residential_address_id_seq RENAME TO chill_person_residential_address_id_seq;'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE IF EXISTS chill_person_residential_address RENAME TO chill_main_residential_address;'); - $this->addSql('ALTER SEQUENCE IF EXISTS chill_person_residential_address_id_seq RENAME TO chill_main_residential_address_id_seq;'); - } } diff --git a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php index a2330bf88..f77a4150c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php @@ -11,10 +11,10 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person\ResidentialAddress; use Chill\PersonBundle\Form\Type\ResidentialAddressType; use Chill\PersonBundle\Repository\ResidentialAddressRepository; -use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\FormType; diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php index c59511552..33cc41dc1 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php @@ -13,12 +13,12 @@ namespace Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; -use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use Symfony\Component\Serializer\Annotation\Groups; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation\Groups; /** * @ORM\Entity(repositoryClass=ResidentialAddressRepository::class) diff --git a/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php b/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php index e7577f336..b34395daf 100644 --- a/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php +++ b/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php @@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Form\Type; use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\PickAddressType; use Chill\PersonBundle\Entity\Person\ResidentialAddress; -use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\DateType; diff --git a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php index 4807fb65e..11ea823fd 100644 --- a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php @@ -17,8 +17,6 @@ use DateTimeImmutable; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; -use function Symfony\Component\DependencyInjection\Loader\Configurator\ref; - /** * @method ResidentialAddress|null find($id, $lockMode = null, $lockVersion = null) * @method ResidentialAddress|null findOneBy(array $criteria, array $orderBy = null) @@ -38,10 +36,11 @@ class ResidentialAddressRepository extends ServiceEntityRepository $date = null === $at ? new DateTimeImmutable('today') : $at; foreach ($addresses as $a) { - if($a->getStartDate() < $date && $a->getEndDate() > $date) { + if ($a->getStartDate() < $date && $a->getEndDate() > $date) { return $a; } } + return null; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 6d2790ab1..66c7a1145 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -41,9 +41,7 @@ class PersonJsonNormalizer implements NormalizerInterface { use DenormalizerAwareTrait; - use NormalizerAwareTrait; - use ObjectToPopulateTrait; private CenterResolverManagerInterface $centerResolverManager; @@ -206,7 +204,7 @@ class PersonJsonNormalizer implements 'gender' => $person->getGender(), 'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress(), $format, $context), 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, - 'current_residential_address' => $currentResidentialAddress ? $this->normalizer->normalize($currentResidentialAddress, $format, $context): null + 'current_residential_address' => $currentResidentialAddress ? $this->normalizer->normalize($currentResidentialAddress, $format, $context) : null, ]; }