diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index de7efb124..9761aa48d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -22,6 +22,7 @@ namespace Chill\PersonBundle\Entity; +use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -93,6 +94,15 @@ class AccompanyingPeriod */ private $user; + /** + * @var Origin + * + * @ORM\ManyToOne( + * targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Origin") + * @ORM\JoinColumn(nullable=true) + */ + private $origin; + /** * AccompanyingPeriod constructor. @@ -355,5 +365,15 @@ class AccompanyingPeriod return $this; } - + + public function getOrigin(): Origin + { + return $this->origin; + } + + public function setOrigin($origin): AccompanyingPeriod + { + $this->origin = $origin; + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php new file mode 100644 index 000000000..4016cd833 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php @@ -0,0 +1,79 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\PersonBundle\Entity\AccompanyingPeriod; + +use Chill\PersonBundle\Entity\AccompanyingPeriod\OriginRepository; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity(repositoryClass=OriginRepository::class) + * @ORM\Table(name="chill_person_accompanying_period_origin") + */ +class Origin +{ + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + */ + private $id; + + /** + * @ORM\Column(type="string", length=255) + */ + private $label; + + /** + * @ORM\Column(type="date_immutable", nullable=true) + */ + private $noActiveAfter; + + public function getId(): ?int + { + return $this->id; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(string $label): self + { + $this->label = $label; + + return $this; + } + + public function getNoActiveAfter(): ?\DateTimeImmutable + { + return $this->noActiveAfter; + } + + public function setNoActiveAfter(?\DateTimeImmutable $noActiveAfter): self + { + $this->noActiveAfter = $noActiveAfter; + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php new file mode 100644 index 000000000..c2283b859 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php @@ -0,0 +1,69 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +namespace Chill\PersonBundle\Repository\AccompanyingPeriod; + +use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; +use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\Persistence\ManagerRegistry; + +/** + * @method Origin|null find($id, $lockMode = null, $lockVersion = null) + * @method Origin|null findOneBy(array $criteria, array $orderBy = null) + * @method Origin[] findAll() + * @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class OriginRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Origin::class); + } + + // /** + // * @return Origin[] Returns an array of Origin objects + // */ + /* + public function findByExampleField($value) + { + return $this->createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('o.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Origin + { + return $this->createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210329090904.php b/src/Bundle/ChillPersonBundle/migrations/Version20210329090904.php new file mode 100644 index 000000000..1ccab6a50 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210329090904.php @@ -0,0 +1,45 @@ +addSql('CREATE SEQUENCE chill_person_accompanying_period_origin_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_person_accompanying_period_origin (id INT NOT NULL, label VARCHAR(255) NOT NULL, noActiveAfter DATE DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_origin.noActiveAfter IS \'(DC2Type:date_immutable)\''); + + $this->addSql('ALTER TABLE chill_person_accompanying_period ADD origin_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86856A273CC FOREIGN KEY (origin_id) REFERENCES chill_person_accompanying_period_origin (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_E260A86856A273CC ON chill_person_accompanying_period (origin_id)'); + + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86856A273CC'); + + $this->addSql('DROP SEQUENCE chill_person_accompanying_period_origin_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_person_accompanying_period_origin'); + + $this->addSql('DROP INDEX IDX_E260A86856A273CC'); + $this->addSql('ALTER TABLE chill_person_accompanying_period DROP origin_id'); + + } +}