From 212aa3e1bd30c81dd472cf427107b0a3d3d0bbf0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 22 Dec 2020 17:25:34 +0100 Subject: [PATCH] Forum - fix entities --- src/CoreBundle/Entity/User.php | 2 +- .../Schema/V200/Version20180927172830.php | 5 ++++ src/CourseBundle/Entity/CForumForum.php | 27 ++++++++++++++++--- src/CourseBundle/Entity/CForumThread.php | 6 ++--- src/CourseBundle/Entity/CLp.php | 25 ++++++++++++++--- src/CourseBundle/Entity/CLpCategory.php | 7 ++++- 6 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/CoreBundle/Entity/User.php b/src/CoreBundle/Entity/User.php index 8136886cb8..b76ff6c401 100644 --- a/src/CoreBundle/Entity/User.php +++ b/src/CoreBundle/Entity/User.php @@ -2304,7 +2304,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface public function getProfileUrl(): string { - return '/social/profile.php?u='.$this->id; + return '/main/social/profile.php?u='.$this->id; } public function getIconStatus(): string diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20180927172830.php b/src/CoreBundle/Migrations/Schema/V200/Version20180927172830.php index 454b7f554b..e67140769c 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20180927172830.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20180927172830.php @@ -51,6 +51,11 @@ class Version20180927172830 extends AbstractMigrationChamilo ); } + $this->addSql('ALTER TABLE c_forum_forum CHANGE lp_id lp_id INT DEFAULT NULL'); + if (false === $table->hasForeignKey('FK_47A9C9968DFD1EF')) { + $this->addSql('ALTER TABLE c_forum_forum ADD CONSTRAINT FK_47A9C9968DFD1EF FOREIGN KEY (lp_id) REFERENCES c_lp (iid)'); + } + if (false === $table->hasIndex('IDX_47A9C9921BF9426')) { $this->addSql('CREATE INDEX IDX_47A9C9921BF9426 ON c_forum_forum (forum_category)'); } diff --git a/src/CourseBundle/Entity/CForumForum.php b/src/CourseBundle/Entity/CForumForum.php index 766a30175d..b167841580 100644 --- a/src/CourseBundle/Entity/CForumForum.php +++ b/src/CourseBundle/Entity/CForumForum.php @@ -188,11 +188,10 @@ class CForumForum extends AbstractResource implements ResourceInterface protected $endTime; /** - * @var int - * - * @ORM\Column(name="lp_id", type="integer", options={"unsigned":true}) + * @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="forum") + * @ORM\JoinColumn(name="lp_id", referencedColumnName="iid") */ - protected $lpId; + protected $lp; /** * @var bool @@ -780,6 +779,26 @@ class CForumForum extends AbstractResource implements ResourceInterface return $this; } + public function getLp(): ?CLp + { + return $this->lp; + } + + public function setLp(CLp $lp): self + { + $this->lp = $lp; + + return $this; + } + + /** + * @return CForumPost[]|ArrayCollection + */ + public function getPosts() + { + return $this->posts; + } + public function getResourceIdentifier(): int { return $this->getIid(); diff --git a/src/CourseBundle/Entity/CForumThread.php b/src/CourseBundle/Entity/CForumThread.php index 6ba1421083..8114c33cc7 100644 --- a/src/CourseBundle/Entity/CForumThread.php +++ b/src/CourseBundle/Entity/CForumThread.php @@ -420,10 +420,8 @@ class CForumThread extends AbstractResource implements ResourceInterface * Set threadQualifyMax. * * @param float $threadQualifyMax - * - * @return CForumThread */ - public function setThreadQualifyMax($threadQualifyMax) + public function setThreadQualifyMax($threadQualifyMax): self { $this->threadQualifyMax = $threadQualifyMax; @@ -471,7 +469,7 @@ class CForumThread extends AbstractResource implements ResourceInterface * * @return CForumThread */ - public function setThreadWeight($threadWeight) + public function setThreadWeight($threadWeight): self { $this->threadWeight = $threadWeight; diff --git a/src/CourseBundle/Entity/CLp.php b/src/CourseBundle/Entity/CLp.php index a75c5d35d5..ac9cd8cac1 100644 --- a/src/CourseBundle/Entity/CLp.php +++ b/src/CourseBundle/Entity/CLp.php @@ -281,8 +281,11 @@ class CLp extends AbstractResource implements ResourceInterface protected $items; /** - * Constructor. + * @var CForumForum + * @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumForum", mappedBy="lp") */ + protected $forum; + public function __construct() { $this->accumulateScormTime = 1; @@ -1080,9 +1083,23 @@ class CLp extends AbstractResource implements ResourceInterface return $this->subscribeUsers; } - /** - * Resource identifier. - */ + public function getForum(): ?CForumForum + { + return $this->forum; + } + + public function hasForum(): bool + { + return null !== $this->forum; + } + + public function setForum(CForumForum $forum): self + { + $this->forum = $forum; + + return $this; + } + public function getResourceIdentifier(): int { return $this->getIid(); diff --git a/src/CourseBundle/Entity/CLpCategory.php b/src/CourseBundle/Entity/CLpCategory.php index 379bec0f0b..3898218e59 100644 --- a/src/CourseBundle/Entity/CLpCategory.php +++ b/src/CourseBundle/Entity/CLpCategory.php @@ -61,7 +61,12 @@ class CLpCategory extends AbstractResource implements ResourceInterface protected $position; /** - * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CLpCategoryUser", mappedBy="category", cascade={"persist", "remove"}, orphanRemoval=true) + * @ORM\OneToMany( + * targetEntity="Chamilo\CourseBundle\Entity\CLpCategoryUser", + * mappedBy="category", + * cascade={"persist", "remove"}, + * orphanRemoval=true + * ) */ protected $users;