Create genderEnum, add genderTranslation property to Gender entity and new gender property to Person entity

Also migrations were created to handle the changes in the database.
This commit is contained in:
2024-09-26 12:20:36 +02:00
parent 8e30873001
commit 94875d83b3
5 changed files with 135 additions and 18 deletions

View File

@@ -21,6 +21,7 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Civility;
use Chill\MainBundle\Entity\Country;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\Language;
use Chill\MainBundle\Entity\User;
@@ -59,19 +60,11 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[HouseholdMembershipSequential(groups: ['household_memberships'])]
class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface, \Stringable
{
final public const BOTH_GENDER = 'both';
// have days in commun
final public const ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD = 2; // where there exist
final public const ERROR_PERIODS_ARE_COLLAPSING = 1; // when two different periods
final public const FEMALE_GENDER = 'woman';
final public const MALE_GENDER = 'man';
final public const NO_INFORMATION = 'unknown';
/**
* Accept receiving email.
*/
@@ -242,11 +235,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
private ?string $fullnameCanonical = '';
/**
* The person's gender.
* NEW column : The person's gender.
*/
#[Assert\NotNull(message: 'The gender must be set')]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 9, nullable: true)]
private ?string $gender = null;
#[ORM\ManyToOne(targetEntity: Gender::class)]
private ?Gender $gender = null;
/**
* Comment on gender.
@@ -1657,6 +1650,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function getGenderKind(): ?Gender
{
return $this->genderKind;
}
public function setGenderKind(?Gender $genderKind): void
{
$this->genderKind = $genderKind;
}
private function getCurrentCenterHistory(): ?PersonCenterHistory
{
if (0 === $this->centerHistory->count()) {