This commit is contained in:
Julien Fastré 2021-12-13 22:57:50 +01:00
parent f2fd30b690
commit f9dd1c5231
5 changed files with 80 additions and 64 deletions

View File

@ -67,6 +67,15 @@ class Evaluation
$this->socialActions = new ArrayCollection(); $this->socialActions = new ArrayCollection();
} }
public function addSocialAction(SocialAction $socialAction): self
{
if (!$this->socialActions->contains($socialAction)) {
$this->socialActions->add($socialAction);
}
return $this;
}
public function getDelay(): ?DateInterval public function getDelay(): ?DateInterval
{ {
return $this->delay; return $this->delay;
@ -87,22 +96,6 @@ class Evaluation
return $this->title; return $this->title;
} }
public function setDelay(DateInterval $delay): self
{
$this->delay = $delay;
return $this;
}
public function addSocialAction(SocialAction $socialAction): self
{
if (!$this->socialActions->contains($socialAction)) {
$this->socialActions->add($socialAction);
}
return $this;
}
public function removeSocialAction(SocialAction $socialAction): self public function removeSocialAction(SocialAction $socialAction): self
{ {
if ($this->socialActions->contains($socialAction)) { if ($this->socialActions->contains($socialAction)) {
@ -112,6 +105,13 @@ class Evaluation
return $this; return $this;
} }
public function setDelay(DateInterval $delay): self
{
$this->delay = $delay;
return $this;
}
public function setNotificationDelay(DateInterval $notificationDelay): self public function setNotificationDelay(DateInterval $notificationDelay): self
{ {
$this->notificationDelay = $notificationDelay; $this->notificationDelay = $notificationDelay;

View File

@ -71,6 +71,11 @@ class SocialAction
*/ */
private $issue; private $issue;
/**
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})
*/
private float $ordering = 0.0;
/** /**
* @ORM\ManyToOne(targetEntity=SocialAction::class, inversedBy="children") * @ORM\ManyToOne(targetEntity=SocialAction::class, inversedBy="children")
*/ */
@ -87,11 +92,6 @@ class SocialAction
*/ */
private $title = []; private $title = [];
/**
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})
*/
private float $ordering = 0.0;
public function __construct() public function __construct()
{ {
$this->children = new ArrayCollection(); $this->children = new ArrayCollection();
@ -100,17 +100,6 @@ class SocialAction
$this->evaluations = new ArrayCollection(); $this->evaluations = new ArrayCollection();
} }
public function getOrdering(): float
{
return $this->ordering;
}
public function setOrdering(float $ordering): SocialAction
{
$this->ordering = $ordering;
return $this;
}
public function addChild(self $child): self public function addChild(self $child): self
{ {
if (!$this->children->contains($child)) { if (!$this->children->contains($child)) {
@ -216,6 +205,11 @@ class SocialAction
return $this->issue; return $this->issue;
} }
public function getOrdering(): float
{
return $this->ordering;
}
public function getParent(): ?self public function getParent(): ?self
{ {
return $this->parent; return $this->parent;
@ -290,6 +284,13 @@ class SocialAction
return $this; return $this;
} }
public function setOrdering(float $ordering): SocialAction
{
$this->ordering = $ordering;
return $this;
}
/** /**
* @internal use $parent->addChild() instead (@see{self::addChild()}) * @internal use $parent->addChild() instead (@see{self::addChild()})
*/ */

View File

@ -44,6 +44,11 @@ class SocialIssue
*/ */
private $id; private $id;
/**
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})
*/
private float $ordering = 0.0;
/** /**
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="children") * @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="children")
*/ */
@ -60,28 +65,12 @@ class SocialIssue
*/ */
private $title = []; private $title = [];
/**
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})
*/
private float $ordering = 0.0;
public function __construct() public function __construct()
{ {
$this->children = new ArrayCollection(); $this->children = new ArrayCollection();
$this->socialActions = new ArrayCollection(); $this->socialActions = new ArrayCollection();
} }
public function getOrdering(): float
{
return $this->ordering;
}
public function setOrdering(float $ordering): SocialIssue
{
$this->ordering = $ordering;
return $this;
}
public function addChild(self $child): self public function addChild(self $child): self
{ {
if (!$this->children->contains($child)) { if (!$this->children->contains($child)) {
@ -231,6 +220,11 @@ class SocialIssue
return $this->id; return $this->id;
} }
public function getOrdering(): float
{
return $this->ordering;
}
public function getParent(): ?self public function getParent(): ?self
{ {
return $this->parent; return $this->parent;
@ -321,6 +315,13 @@ class SocialIssue
return $this; return $this;
} }
public function setOrdering(float $ordering): SocialIssue
{
$this->ordering = $ordering;
return $this;
}
/** /**
* @internal use @see{SocialIssue::addChild()} instead * @internal use @see{SocialIssue::addChild()} instead
*/ */

View File

@ -1,5 +1,12 @@
<?php <?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1); declare(strict_types=1);
namespace Chill\Migrations\Person; namespace Chill\Migrations\Person;
@ -8,10 +15,18 @@ use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/** /**
* change model: an evaluation may be linked with multiple social actions * change model: an evaluation may be linked with multiple social actions.
*/ */
final class Version20211213203147 extends AbstractMigration final class Version20211213203147 extends AbstractMigration
{ {
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE chill_person_social_work_evaluation_action');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD socialaction_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD CONSTRAINT fk_2e23f3febf32a3da FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_2e23f3febf32a3da ON chill_person_social_work_evaluation (socialaction_id)');
}
public function getDescription(): string public function getDescription(): string
{ {
return 'an evaluation may be linked with multiple social actions'; return 'an evaluation may be linked with multiple social actions';
@ -25,19 +40,11 @@ final class Version20211213203147 extends AbstractMigration
$this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB456C5646 FOREIGN KEY (evaluation_id) REFERENCES chill_person_social_work_evaluation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB456C5646 FOREIGN KEY (evaluation_id) REFERENCES chill_person_social_work_evaluation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB3DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB3DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('INSERT INTO chill_person_social_work_evaluation_action (evaluation_id, socialaction_id) '. $this->addSql('INSERT INTO chill_person_social_work_evaluation_action (evaluation_id, socialaction_id) ' .
'SELECT id, socialaction_ID FROM chill_person_social_work_evaluation'); 'SELECT id, socialaction_ID FROM chill_person_social_work_evaluation');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP CONSTRAINT fk_2e23f3febf32a3da'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP CONSTRAINT fk_2e23f3febf32a3da');
$this->addSql('DROP INDEX idx_2e23f3febf32a3da'); $this->addSql('DROP INDEX idx_2e23f3febf32a3da');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP socialaction_id'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP socialaction_id');
} }
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE chill_person_social_work_evaluation_action');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD socialaction_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD CONSTRAINT fk_2e23f3febf32a3da FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_2e23f3febf32a3da ON chill_person_social_work_evaluation (socialaction_id)');
}
} }

View File

@ -1,5 +1,12 @@
<?php <?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1); declare(strict_types=1);
namespace Chill\Migrations\Person; namespace Chill\Migrations\Person;
@ -9,6 +16,12 @@ use Doctrine\Migrations\AbstractMigration;
final class Version20211213213755 extends AbstractMigration final class Version20211213213755 extends AbstractMigration
{ {
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_action DROP ordering');
$this->addSql('ALTER TABLE chill_person_social_issue DROP ordering');
}
public function getDescription(): string public function getDescription(): string
{ {
return 'Add ordering to social issue and social actions'; return 'Add ordering to social issue and social actions';
@ -19,10 +32,4 @@ final class Version20211213213755 extends AbstractMigration
$this->addSql('ALTER TABLE chill_person_social_action ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL'); $this->addSql('ALTER TABLE chill_person_social_action ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL');
$this->addSql('ALTER TABLE chill_person_social_issue ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL'); $this->addSql('ALTER TABLE chill_person_social_issue ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL');
} }
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_action DROP ordering');
$this->addSql('ALTER TABLE chill_person_social_issue DROP ordering');
}
} }