Minor - format code

pull/4014/head^2
Julio 3 years ago
parent 1c5d741899
commit ade3211e3a
  1. 4
      src/CoreBundle/Entity/Session.php
  2. 4
      src/CoreBundle/Entity/User.php
  3. 12
      src/CoreBundle/Repository/SessionRepository.php
  4. 7
      tests/CoreBundle/Repository/Node/CourseRepositoryTest.php

@ -361,12 +361,12 @@ class Session implements ResourceWithAccessUrlInterface
}
}
public function addUserInSession(int $status, User $user): self
public function addUserInSession(int $relationType, User $user): self
{
$sessionRelUser = (new SessionRelUser())
->setSession($this)
->setUser($user)
->setRelationType($status)
->setRelationType($relationType)
;
$this->addUser($sessionRelUser);

@ -2265,8 +2265,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
/**
* Retrieves this user's related sessions.
*
* @param int $relationType
*
* @return Session[]
*/
public function getSessions(int $relationType): array
@ -2294,8 +2292,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
/**
* Get this user's related accessible sessions of a type, student by default.
*
* @param int $relationType
*
* @return Session[]
*/
public function getCurrentlyAccessibleSessions(int $relationType = Session::STUDENT): array

@ -81,7 +81,7 @@ class SessionRepository extends ServiceEntityRepository
return $qb->getQuery()->getResult();
}
public function addUserInCourse(int $status, User $user, Course $course, Session $session): void
public function addUserInCourse(int $relationType, User $user, Course $course, Session $session): void
{
if (!$session->isActive()) {
throw new Exception('Session not active');
@ -101,7 +101,7 @@ class SessionRepository extends ServiceEntityRepository
throw new Exception($msg);
}
switch ($status) {
switch ($relationType) {
case Session::DRH:
if ($user->hasRole('ROLE_RRHH')) {
$session->addUserInSession(Session::DRH, $user);
@ -111,11 +111,7 @@ class SessionRepository extends ServiceEntityRepository
case Session::STUDENT:
$session
->addUserInSession(Session::STUDENT, $user)
->addUserInCourse(
Session::STUDENT,
$user,
$course
)
->addUserInCourse(Session::STUDENT, $user, $course)
;
break;
@ -130,7 +126,7 @@ class SessionRepository extends ServiceEntityRepository
break;
default:
throw new Exception(sprintf('Cannot handle status %s', $status));
throw new Exception(sprintf('Cannot handle relationType %s', $relationType));
}
}

@ -12,6 +12,7 @@ use Chamilo\CoreBundle\Entity\CourseRelUser;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
use DateTime;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
class CourseRepositoryTest extends AbstractApiTest
@ -58,9 +59,9 @@ class CourseRepositoryTest extends AbstractApiTest
->setDescription('desc')
->setShowScore(0)
->setDiskQuota(0)
->setLastVisit(new \DateTime())
->setCreationDate(new \DateTime())
->setExpirationDate(new \DateTime())
->setLastVisit(new DateTime())
->setCreationDate(new DateTime())
->setExpirationDate(new DateTime())
->setSubscribe(true)
->setUnsubscribe(false)
->setVideoUrl('https://example.com/video.mp4')

Loading…
Cancel
Save