Skip to content

Commit 0b35a31

Browse files
committed
Internal - Update entities from Seb's PR
#3372
1 parent 4ab6d1a commit 0b35a31

File tree

7 files changed

+133
-132
lines changed

7 files changed

+133
-132
lines changed

src/CoreBundle/Entity/AccessUrl.php

+44-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Chamilo\CoreBundle\Entity;
66

77
use ApiPlatform\Core\Annotation\ApiResource;
8-
use Chamilo\CoreBundle\Traits\CourseTrait;
98
use Doctrine\ORM\Mapping as ORM;
109
use Gedmo\Mapping\Annotation as Gedmo;
1110
use Symfony\Component\Serializer\Annotation\Groups;
@@ -24,8 +23,6 @@
2423
*/
2524
class AccessUrl extends AbstractResource implements ResourceInterface
2625
{
27-
use CourseTrait;
28-
2926
/**
3027
* @var int
3128
*
@@ -40,12 +37,12 @@ class AccessUrl extends AbstractResource implements ResourceInterface
4037
/**
4138
* @ORM\OneToMany(targetEntity="AccessUrlRelCourse", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
4239
*/
43-
protected $course;
40+
protected $courses;
4441

4542
/**
4643
* @ORM\OneToMany(targetEntity="AccessUrlRelSession", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
4744
*/
48-
protected $session;
45+
protected $sessions;
4946

5047
/**
5148
* @ORM\OneToMany(targetEntity="AccessUrlRelUser", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
@@ -58,9 +55,14 @@ class AccessUrl extends AbstractResource implements ResourceInterface
5855
protected $settings;
5956

6057
/**
61-
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionCategory", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
58+
* @ORM\OneToMany(
59+
* targetEntity="Chamilo\CoreBundle\Entity\SessionCategory",
60+
* mappedBy="url",
61+
* cascade={"persist"},
62+
* orphanRemoval=true
63+
* )
6264
*/
63-
protected $sessionCategory;
65+
protected $sessionCategories;
6466

6567
/**
6668
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelCourseCategory", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
@@ -511,37 +513,62 @@ public function setSettings($settings)
511513
return $this;
512514
}
513515

514-
public function getSessionCategory()
516+
/**
517+
* @return int
518+
*/
519+
public function getLimitCourses()
515520
{
516-
return $this->sessionCategory;
521+
return $this->limitCourses;
517522
}
518523

519524
/**
525+
* @param int $limitCourses
526+
*
520527
* @return AccessUrl
521528
*/
522-
public function setSessionCategory($sessionCategory)
529+
public function setLimitCourses($limitCourses)
523530
{
524-
$this->sessionCategory = $sessionCategory;
531+
$this->limitCourses = $limitCourses;
525532

526533
return $this;
527534
}
528535

529536
/**
530-
* @return int
537+
* @return mixed
531538
*/
532-
public function getLimitCourses()
539+
public function getCourses()
533540
{
534-
return $this->limitCourses;
541+
return $this->courses;
535542
}
536543

537544
/**
538-
* @param int $limitCourses
545+
* @param mixed $courses
539546
*
540547
* @return AccessUrl
541548
*/
542-
public function setLimitCourses($limitCourses)
549+
public function setCourses($courses)
543550
{
544-
$this->limitCourses = $limitCourses;
551+
$this->courses = $courses;
552+
553+
return $this;
554+
}
555+
556+
/**
557+
* @return mixed
558+
*/
559+
public function getSessionCategories()
560+
{
561+
return $this->sessionCategories;
562+
}
563+
564+
/**
565+
* @param mixed $sessionCategories
566+
*
567+
* @return AccessUrl
568+
*/
569+
public function setSessionCategories($sessionCategories)
570+
{
571+
$this->sessionCategories = $sessionCategories;
545572

546573
return $this;
547574
}

src/CoreBundle/Entity/Course.php

+23-15
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
116116
protected $resourceLinks;
117117

118118
/**
119+
* @var ArrayCollection|AccessUrlRelCourse[]
119120
* @ORM\OneToMany(targetEntity="AccessUrlRelCourse", mappedBy="course", cascade={"persist", "remove"}, orphanRemoval=true)
120121
*/
121122
protected $urls;
@@ -433,16 +434,20 @@ public function setTools($tools)
433434
foreach ($tools as $tool) {
434435
$this->addTool($tool);
435436
}
437+
438+
return $this;
436439
}
437440

438441
public function addTool(CTool $tool)
439442
{
440443
$tool->setCourse($this);
441444
$this->tools[] = $tool;
445+
446+
return $this;
442447
}
443448

444449
/**
445-
* @return ArrayCollection
450+
* @return AccessUrlRelCourse[]|ArrayCollection
446451
*/
447452
public function getUrls()
448453
{
@@ -458,12 +463,16 @@ public function setUrls(ArrayCollection $urls)
458463
foreach ($urls as $url) {
459464
$this->addUrl($url);
460465
}
466+
467+
return $this;
461468
}
462469

463470
public function addUrlRelCourse(AccessUrlRelCourse $url)
464471
{
465472
$url->setCourse($this);
466473
$this->urls[] = $url;
474+
475+
return $this;
467476
}
468477

469478
public function addUrl(AccessUrl $url)
@@ -472,6 +481,8 @@ public function addUrl(AccessUrl $url)
472481
$urlRelCourse->setCourse($this);
473482
$urlRelCourse->setUrl($url);
474483
$this->addUrlRelCourse($urlRelCourse);
484+
485+
return $this;
475486
}
476487

477488
/**
@@ -522,6 +533,8 @@ public function setUsers($users)
522533
foreach ($users as $user) {
523534
$this->addUsers($user);
524535
}
536+
537+
return $this;
525538
}
526539

527540
public function addUsers(CourseRelUser $courseRelUser)
@@ -531,6 +544,8 @@ public function addUsers(CourseRelUser $courseRelUser)
531544
if (!$this->hasSubscription($courseRelUser)) {
532545
$this->users[] = $courseRelUser;
533546
}
547+
548+
return $this;
534549
}
535550

536551
/**
@@ -596,21 +611,15 @@ public function removeUsers(CourseRelUser $user)
596611
public function addTeacher(User $user)
597612
{
598613
$this->addUser($user, 0, 'Trainer', User::COURSE_MANAGER);
614+
615+
return $this;
599616
}
600617

601618
public function addStudent(User $user)
602619
{
603620
$this->addUser($user, 0, '', User::STUDENT);
604-
}
605621

606-
/**
607-
* Set id.
608-
*
609-
* @return int
610-
*/
611-
public function setId($id)
612-
{
613-
$this->id = $id;
622+
return $this;
614623
}
615624

616625
/**
@@ -1335,10 +1344,7 @@ public function getIssuedSkills()
13351344
return $this->issuedSkills;
13361345
}
13371346

1338-
/**
1339-
* @return bool
1340-
*/
1341-
public function hasSubscription(CourseRelUser $subscription)
1347+
public function hasSubscription(CourseRelUser $subscription): bool
13421348
{
13431349
if ($this->getUsers()->count()) {
13441350
$criteria = Criteria::create()->where(
@@ -1362,7 +1368,7 @@ public function hasSubscription(CourseRelUser $subscription)
13621368
* @param string $role
13631369
* @param string $status
13641370
*/
1365-
public function addUser(User $user, $relationType, $role, $status)
1371+
public function addUser(User $user, $relationType, $role, $status): self
13661372
{
13671373
$courseRelUser = new CourseRelUser();
13681374
$courseRelUser->setCourse($this);
@@ -1371,6 +1377,8 @@ public function addUser(User $user, $relationType, $role, $status)
13711377
//$courseRelUser->setRole($role);
13721378
$courseRelUser->setStatus($status);
13731379
$this->addUsers($courseRelUser);
1380+
1381+
return $this;
13741382
}
13751383

13761384
/**

src/CoreBundle/Entity/CourseRelUser.php

+7-27
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ public function getId()
125125
return $this->id;
126126
}
127127

128-
/**
129-
* @return $this
130-
*/
131-
public function setCourse(Course $course)
128+
public function setCourse(Course $course): self
132129
{
133130
$this->course = $course;
134131

@@ -145,12 +142,7 @@ public function getCourse()
145142
return $this->course;
146143
}
147144

148-
/**
149-
* @param User $user
150-
*
151-
* @return $this
152-
*/
153-
public function setUser($user)
145+
public function setUser(User $user): self
154146
{
155147
$this->user = $user;
156148

@@ -159,22 +151,16 @@ public function setUser($user)
159151

160152
/**
161153
* Get User.
162-
*
163-
* @return User
164154
*/
165-
public function getUser()
155+
public function getUser(): User
166156
{
167157
return $this->user;
168158
}
169159

170160
/**
171161
* Set relationType.
172-
*
173-
* @param int $relationType
174-
*
175-
* @return CourseRelUser
176162
*/
177-
public function setRelationType($relationType)
163+
public function setRelationType(int $relationType): self
178164
{
179165
$this->relationType = $relationType;
180166

@@ -183,10 +169,8 @@ public function setRelationType($relationType)
183169

184170
/**
185171
* Get relationType.
186-
*
187-
* @return int
188172
*/
189-
public function getRelationType()
173+
public function getRelationType(): int
190174
{
191175
return $this->relationType;
192176
}
@@ -195,10 +179,8 @@ public function getRelationType()
195179
* Set status.
196180
*
197181
* @param bool $status
198-
*
199-
* @return CourseRelUser
200182
*/
201-
public function setStatus($status)
183+
public function setStatus($status): self
202184
{
203185
$this->status = $status;
204186

@@ -219,10 +201,8 @@ public function getStatus()
219201
* Set sort.
220202
*
221203
* @param int $sort
222-
*
223-
* @return CourseRelUser
224204
*/
225-
public function setSort($sort)
205+
public function setSort($sort): self
226206
{
227207
$this->sort = $sort;
228208

src/CoreBundle/Entity/Session.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,16 @@ public function addUser(SessionRelUser $user)
420420
/**
421421
* @param int $status
422422
*/
423-
public function addUserInSession($status, User $user)
423+
public function addUserInSession($status, User $user): self
424424
{
425425
$sessionRelUser = new SessionRelUser();
426426
$sessionRelUser->setSession($this);
427427
$sessionRelUser->setUser($user);
428428
$sessionRelUser->setRelationType($status);
429429

430430
$this->addUser($sessionRelUser);
431+
432+
return $this;
431433
}
432434

433435
/**
@@ -478,10 +480,7 @@ public function addCourses(SessionRelCourse $course)
478480
$this->courses[] = $course;
479481
}
480482

481-
/**
482-
* @return bool
483-
*/
484-
public function hasCourse(Course $course)
483+
public function hasCourse(Course $course): bool
485484
{
486485
if ($this->getCourses()->count()) {
487486
$criteria = Criteria::create()->where(

0 commit comments

Comments
 (0)