From 690a443bdbb361d5a69f895edbd9c371b40aecd3 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 16:25:05 +0100 Subject: [PATCH] fix code style for AccompanyingPeriodWork - referrers --- .../AccompanyingPeriodWork.php | 48 +++++++++---------- .../AccompanyingPeriodWorkEventListener.php | 3 +- .../migrations/Version20220310063629.php | 12 ++--- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index f9f9f46e1..95ec008d9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -237,6 +237,15 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + public function addReferrer(User $referrer): self + { + if (!$this->referrers->contains($referrer)) { + $this->referrers[] = $referrer; + } + + return $this; + } + public function addResult(Result $result): self { if (!$this->results->contains($result)) { @@ -318,6 +327,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->persons; } + /** + * @return Collection|User[] + */ + public function getReferrers(): Collection + { + return $this->referrers; + } + /** * @return Collection|Result[] */ @@ -392,6 +409,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + public function removeReferrer(User $referrer): self + { + $this->referrers->removeElement($referrer); + + return $this; + } + public function removeResult(Result $result): self { $this->results->removeElement($result); @@ -507,28 +531,4 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } - - /** - * @return Collection|User[] - */ - public function getReferrers(): Collection - { - return $this->referrers; - } - - public function addReferrer(User $referrer): self - { - if (!$this->referrers->contains($referrer)) { - $this->referrers[] = $referrer; - } - - return $this; - } - - public function removeReferrer(User $referrer): self - { - $this->referrers->removeElement($referrer); - - return $this; - } } diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php index ab767802f..c9b11ea71 100644 --- a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -11,12 +11,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\EventListener; -use Symfony\Component\Security\Core\Security; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; +use Symfony\Component\Security\Core\Security; class AccompanyingPeriodWorkEventListener { - private Security $security; public function __construct(Security $security) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php index 0d56ff4b1..2b4c171a2 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php @@ -15,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Add referrers to AccompanyingPeriodWork + * Add referrers to AccompanyingPeriodWork. */ final class Version20220310063629 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE chill_person_accompanying_period_work_referrer'); + } + public function getDescription(): string { return 'Add referrers to AccompanyingPeriodWork'; @@ -32,9 +37,4 @@ final class Version20220310063629 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP TABLE chill_person_accompanying_period_work_referrer'); - } }