| Total Complexity | 104 |
| Total Lines | 1349 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Course often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Course, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 51 | class Course extends AbstractResource implements ResourceInterface, ResourceWithUrlInterface, ResourceToRootInterface |
||
| 52 | { |
||
| 53 | public const CLOSED = 0; |
||
| 54 | public const REGISTERED = 1; |
||
| 55 | public const OPEN_PLATFORM = 2; |
||
| 56 | public const OPEN_WORLD = 3; |
||
| 57 | public const HIDDEN = 4; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var int |
||
| 61 | * |
||
| 62 | * @Groups({"course:read", "course_rel_user:read"}) |
||
| 63 | * @ORM\Column(name="id", type="integer", nullable=false, unique=false) |
||
| 64 | * @ORM\Id |
||
| 65 | * @ORM\GeneratedValue(strategy="AUTO") |
||
| 66 | */ |
||
| 67 | protected $id; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var string The course title |
||
| 71 | * |
||
| 72 | * @Assert\NotBlank(message="A Course requires a title") |
||
| 73 | * |
||
| 74 | * @Groups({"course:read", "course:write", "course_rel_user:read", "session_rel_course_rel_user:read"}) |
||
| 75 | * |
||
| 76 | * @ORM\Column(name="title", type="string", length=250, nullable=true, unique=false) |
||
| 77 | */ |
||
| 78 | protected $title; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var string |
||
| 82 | * @Assert\NotBlank() |
||
| 83 | * @ApiProperty(iri="http://schema.org/courseCode") |
||
| 84 | * @Groups({"course:read", "course:write", "course_rel_user:read"}) |
||
| 85 | * |
||
| 86 | * @Gedmo\Slug( |
||
| 87 | * fields={"title"}, |
||
| 88 | * updatable = false, |
||
| 89 | * unique = true, |
||
| 90 | * style = "upper" |
||
| 91 | * ) |
||
| 92 | * @ORM\Column(name="code", type="string", length=40, nullable=false, unique=true) |
||
| 93 | */ |
||
| 94 | protected $code; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var CourseRelUser[]|ArrayCollection |
||
| 98 | * |
||
| 99 | * @ApiSubresource() |
||
| 100 | * Groups({"course:read"}) |
||
| 101 | * "orphanRemoval" is needed to delete the CourseRelUser relation |
||
| 102 | * in the CourseAdmin class. The setUsers, getUsers, removeUsers and |
||
| 103 | * addUsers methods need to be added. |
||
| 104 | * |
||
| 105 | * @ORM\OneToMany(targetEntity="CourseRelUser", mappedBy="course", cascade={"persist"}, orphanRemoval=true) |
||
| 106 | */ |
||
| 107 | protected $users; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @var ArrayCollection|ResourceLink[] |
||
| 111 | * |
||
| 112 | * ApiSubresource() |
||
| 113 | * Groups({"course:read"}) |
||
| 114 | * @ORM\OneToMany(targetEntity="ResourceLink", mappedBy="course", cascade={"persist"}, orphanRemoval=true) |
||
| 115 | */ |
||
| 116 | protected $resourceLinks; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @ORM\OneToMany(targetEntity="AccessUrlRelCourse", mappedBy="course", cascade={"persist", "remove"}, orphanRemoval=true) |
||
| 120 | */ |
||
| 121 | protected $urls; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @var SessionRelCourse[] |
||
| 125 | * |
||
| 126 | * @ORM\OneToMany(targetEntity="SessionRelCourse", mappedBy="course", cascade={"persist", "remove"}) |
||
| 127 | */ |
||
| 128 | protected $sessions; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @ORM\OneToMany(targetEntity="SessionRelCourseRelUser", mappedBy="course", cascade={"persist", "remove"}) |
||
| 132 | */ |
||
| 133 | protected $sessionUserSubscriptions; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @var CTool[]|ArrayCollection |
||
| 137 | * |
||
| 138 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CTool", mappedBy="course", cascade={"persist", "remove"}) |
||
| 139 | */ |
||
| 140 | protected $tools; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @var Session |
||
| 144 | */ |
||
| 145 | protected $currentSession; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @var AccessUrl |
||
| 149 | */ |
||
| 150 | protected $currentUrl; |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @ORM\OneToMany(targetEntity="SkillRelCourse", mappedBy="course", cascade={"persist", "remove"}) |
||
| 154 | */ |
||
| 155 | protected $skills; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @ORM\OneToMany(targetEntity="SkillRelUser", mappedBy="course", cascade={"persist", "remove"}) |
||
| 159 | */ |
||
| 160 | protected $issuedSkills; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @ORM\OneToMany(targetEntity="GradebookCategory", mappedBy="course", cascade={"persist", "remove"}) |
||
| 164 | */ |
||
| 165 | protected $gradebookCategories; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @ORM\OneToMany(targetEntity="GradebookEvaluation", mappedBy="course", cascade={"persist", "remove"}) |
||
| 169 | */ |
||
| 170 | protected $gradebookEvaluations; |
||
| 171 | |||
| 172 | /** |
||
| 173 | * @ORM\OneToMany(targetEntity="GradebookLink", mappedBy="course", cascade={"persist", "remove"}) |
||
| 174 | */ |
||
| 175 | protected $gradebookLinks; |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @ORM\OneToMany(targetEntity="TrackEHotspot", mappedBy="course", cascade={"persist", "remove"}) |
||
| 179 | */ |
||
| 180 | protected $trackEHotspots; |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\TrackEAttempt", mappedBy="course", cascade={"persist", "remove"}) |
||
| 184 | */ |
||
| 185 | protected $trackEAttempts; |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SearchEngineRef", mappedBy="course", cascade={"persist", "remove"}) |
||
| 189 | */ |
||
| 190 | protected $searchEngineRefs; |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Templates", mappedBy="course", cascade={"persist", "remove"}) |
||
| 194 | */ |
||
| 195 | protected $templates; |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SpecificFieldValues", mappedBy="course") |
||
| 199 | */ |
||
| 200 | //protected $specificFieldValues; |
||
| 201 | |||
| 202 | /** |
||
| 203 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SharedSurvey", mappedBy="course") |
||
| 204 | */ |
||
| 205 | //protected $sharedSurveys; |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @var string |
||
| 209 | * |
||
| 210 | * @ORM\Column(name="directory", type="string", length=40, nullable=true, unique=false) |
||
| 211 | */ |
||
| 212 | protected $directory; |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @var string |
||
| 216 | * @Groups({"course:read", "list"}) |
||
| 217 | * @ORM\Column(name="course_language", type="string", length=20, nullable=true, unique=false) |
||
| 218 | */ |
||
| 219 | protected $courseLanguage; |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @var string |
||
| 223 | * |
||
| 224 | * @ORM\Column(name="description", type="text", nullable=true, unique=false) |
||
| 225 | */ |
||
| 226 | protected $description; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @var ArrayCollection |
||
| 230 | * @ApiSubresource() |
||
| 231 | * @Groups({"course:read", "course:write"}) |
||
| 232 | * @ORM\ManyToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseCategory", inversedBy="courses") |
||
| 233 | * @ORM\JoinTable( |
||
| 234 | * name="course_rel_category", |
||
| 235 | * joinColumns={@ORM\JoinColumn(name="course_id", referencedColumnName="id")}, |
||
| 236 | * inverseJoinColumns={@ORM\JoinColumn(name="course_category_id", referencedColumnName="id")} |
||
| 237 | * ) |
||
| 238 | */ |
||
| 239 | protected $categories; |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @var int Course visibility |
||
| 243 | * |
||
| 244 | * @Groups({"course:read", "course:write"}) |
||
| 245 | * @Assert\NotBlank() |
||
| 246 | * |
||
| 247 | * @ORM\Column(name="visibility", type="integer", nullable=true, unique=false) |
||
| 248 | */ |
||
| 249 | protected $visibility; |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @var int |
||
| 253 | * |
||
| 254 | * @ORM\Column(name="show_score", type="integer", nullable=true, unique=false) |
||
| 255 | */ |
||
| 256 | protected $showScore; |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @var string |
||
| 260 | * |
||
| 261 | * @ORM\Column(name="tutor_name", type="string", length=200, nullable=true, unique=false) |
||
| 262 | */ |
||
| 263 | protected $tutorName; |
||
| 264 | |||
| 265 | /** |
||
| 266 | * @var string |
||
| 267 | * |
||
| 268 | * @ORM\Column(name="visual_code", type="string", length=40, nullable=true, unique=false) |
||
| 269 | */ |
||
| 270 | protected $visualCode; |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @var string |
||
| 274 | * |
||
| 275 | * @Groups({"course:read", "list"}) |
||
| 276 | * @ORM\Column(name="department_name", type="string", length=30, nullable=true, unique=false) |
||
| 277 | */ |
||
| 278 | protected $departmentName; |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @var string |
||
| 282 | * @Groups({"course:read", "list"}) |
||
| 283 | * @Assert\Url() |
||
| 284 | * |
||
| 285 | * @ORM\Column(name="department_url", type="string", length=180, nullable=true, unique=false) |
||
| 286 | */ |
||
| 287 | protected $departmentUrl; |
||
| 288 | |||
| 289 | /** |
||
| 290 | * @var int |
||
| 291 | * |
||
| 292 | * @ORM\Column(name="disk_quota", type="bigint", nullable=true, unique=false) |
||
| 293 | */ |
||
| 294 | protected $diskQuota; |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @var \DateTime |
||
| 298 | * |
||
| 299 | * @ORM\Column(name="last_visit", type="datetime", nullable=true, unique=false) |
||
| 300 | */ |
||
| 301 | protected $lastVisit; |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @var \DateTime |
||
| 305 | * |
||
| 306 | * @ORM\Column(name="last_edit", type="datetime", nullable=true, unique=false) |
||
| 307 | */ |
||
| 308 | protected $lastEdit; |
||
| 309 | |||
| 310 | /** |
||
| 311 | * @var \DateTime |
||
| 312 | * |
||
| 313 | * @ORM\Column(name="creation_date", type="datetime", nullable=true, unique=false) |
||
| 314 | */ |
||
| 315 | protected $creationDate; |
||
| 316 | |||
| 317 | /** |
||
| 318 | * @var \DateTime |
||
| 319 | * @Groups({"course:read", "list"}) |
||
| 320 | * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false) |
||
| 321 | */ |
||
| 322 | protected $expirationDate; |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @var bool |
||
| 326 | * |
||
| 327 | * @ORM\Column(name="subscribe", type="boolean", nullable=true, unique=false) |
||
| 328 | */ |
||
| 329 | protected $subscribe; |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @var bool |
||
| 333 | * |
||
| 334 | * @ORM\Column(name="unsubscribe", type="boolean", nullable=true, unique=false) |
||
| 335 | */ |
||
| 336 | protected $unsubscribe; |
||
| 337 | |||
| 338 | /** |
||
| 339 | * @var string |
||
| 340 | * |
||
| 341 | * @ORM\Column(name="registration_code", type="string", length=255, nullable=true, unique=false) |
||
| 342 | */ |
||
| 343 | protected $registrationCode; |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @var string |
||
| 347 | * |
||
| 348 | * @ORM\Column(name="legal", type="text", nullable=true, unique=false) |
||
| 349 | */ |
||
| 350 | protected $legal; |
||
| 351 | |||
| 352 | /** |
||
| 353 | * @var int |
||
| 354 | * |
||
| 355 | * @ORM\Column(name="activate_legal", type="integer", nullable=true, unique=false) |
||
| 356 | */ |
||
| 357 | protected $activateLegal; |
||
| 358 | |||
| 359 | /** |
||
| 360 | * @var bool |
||
| 361 | * |
||
| 362 | * @ORM\Column(name="add_teachers_to_sessions_courses", type="boolean", nullable=true) |
||
| 363 | */ |
||
| 364 | protected $addTeachersToSessionsCourses; |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @var int |
||
| 368 | * |
||
| 369 | * @ORM\Column(name="course_type_id", type="integer", nullable=true, unique=false) |
||
| 370 | */ |
||
| 371 | protected $courseTypeId; |
||
| 372 | |||
| 373 | /** |
||
| 374 | * ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course"). |
||
| 375 | */ |
||
| 376 | //protected $curriculumCategories; |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @var Room |
||
| 380 | * |
||
| 381 | * @ORM\ManyToOne(targetEntity="Room") |
||
| 382 | * @ORM\JoinColumn(name="room_id", referencedColumnName="id") |
||
| 383 | */ |
||
| 384 | protected $room; |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Constructor. |
||
| 388 | */ |
||
| 389 | public function __construct() |
||
| 390 | { |
||
| 391 | $this->creationDate = new \DateTime(); |
||
| 392 | $this->lastVisit = new \DateTime(); |
||
| 393 | $this->lastEdit = new \DateTime(); |
||
| 394 | |||
| 395 | $this->users = new ArrayCollection(); |
||
| 396 | $this->urls = new ArrayCollection(); |
||
| 397 | $this->tools = new ArrayCollection(); |
||
| 398 | $this->categories = new ArrayCollection(); |
||
| 399 | $this->gradebookCategories = new ArrayCollection(); |
||
| 400 | $this->gradebookEvaluations = new ArrayCollection(); |
||
| 401 | $this->gradebookLinks = new ArrayCollection(); |
||
| 402 | $this->trackEHotspots = new ArrayCollection(); |
||
| 403 | $this->trackEAttempts = new ArrayCollection(); |
||
| 404 | $this->searchEngineRefs = new ArrayCollection(); |
||
| 405 | $this->templates = new ArrayCollection(); |
||
| 406 | $this->specificFieldValues = new ArrayCollection(); |
||
| 407 | $this->sharedSurveys = new ArrayCollection(); |
||
| 408 | } |
||
| 409 | |||
| 410 | public function __toString(): string |
||
| 411 | { |
||
| 412 | return $this->getTitle(); |
||
| 413 | } |
||
| 414 | |||
| 415 | /** |
||
| 416 | * @return SessionRelCourse[]|ArrayCollection |
||
| 417 | */ |
||
| 418 | public function getSessions() |
||
| 419 | { |
||
| 420 | return $this->sessions; |
||
| 421 | } |
||
| 422 | |||
| 423 | public function getTools() |
||
| 424 | { |
||
| 425 | return $this->tools; |
||
| 426 | } |
||
| 427 | |||
| 428 | /** |
||
| 429 | * @param array $tools |
||
| 430 | */ |
||
| 431 | public function setTools($tools) |
||
| 432 | { |
||
| 433 | foreach ($tools as $tool) { |
||
| 434 | $this->addTool($tool); |
||
| 435 | } |
||
| 436 | } |
||
| 437 | |||
| 438 | public function addTool(CTool $tool) |
||
| 439 | { |
||
| 440 | $tool->setCourse($this); |
||
| 441 | $this->tools[] = $tool; |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * @return ArrayCollection |
||
| 446 | */ |
||
| 447 | public function getUrls() |
||
| 448 | { |
||
| 449 | return $this->urls; |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @param $urls |
||
| 454 | */ |
||
| 455 | public function setUrls(ArrayCollection $urls) |
||
| 456 | { |
||
| 457 | $this->urls = new ArrayCollection(); |
||
| 458 | foreach ($urls as $url) { |
||
| 459 | $this->addUrl($url); |
||
| 460 | } |
||
| 461 | } |
||
| 462 | |||
| 463 | public function addUrlRelCourse(AccessUrlRelCourse $url) |
||
| 464 | { |
||
| 465 | $url->setCourse($this); |
||
| 466 | $this->urls[] = $url; |
||
| 467 | } |
||
| 468 | |||
| 469 | public function addUrl(AccessUrl $url) |
||
| 470 | { |
||
| 471 | $urlRelCourse = new AccessUrlRelCourse(); |
||
| 472 | $urlRelCourse->setCourse($this); |
||
| 473 | $urlRelCourse->setUrl($url); |
||
| 474 | $this->addUrlRelCourse($urlRelCourse); |
||
| 475 | } |
||
| 476 | |||
| 477 | /** |
||
| 478 | * @return CourseRelUser[]|ArrayCollection |
||
| 479 | */ |
||
| 480 | public function getUsers() |
||
| 481 | { |
||
| 482 | return $this->users; |
||
| 483 | } |
||
| 484 | |||
| 485 | /** |
||
| 486 | * @return CGroup[]|ArrayCollection |
||
| 487 | */ |
||
| 488 | public function getGroups() |
||
| 489 | { |
||
| 490 | return $this->groups; |
||
|
|
|||
| 491 | } |
||
| 492 | |||
| 493 | /** |
||
| 494 | * @return CourseRelUser[]|ArrayCollection |
||
| 495 | */ |
||
| 496 | public function getTeachers() |
||
| 497 | { |
||
| 498 | $criteria = Criteria::create(); |
||
| 499 | $criteria->where(Criteria::expr()->eq('status', User::COURSE_MANAGER)); |
||
| 500 | |||
| 501 | return $this->users->matching($criteria); |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @return CourseRelUser[]|ArrayCollection |
||
| 506 | */ |
||
| 507 | public function getStudents() |
||
| 508 | { |
||
| 509 | $criteria = Criteria::create(); |
||
| 510 | $criteria->where(Criteria::expr()->eq('status', User::STUDENT)); |
||
| 511 | |||
| 512 | return $this->users->matching($criteria); |
||
| 513 | } |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @param ArrayCollection $users |
||
| 517 | */ |
||
| 518 | public function setUsers($users) |
||
| 519 | { |
||
| 520 | $this->users = new ArrayCollection(); |
||
| 521 | |||
| 522 | foreach ($users as $user) { |
||
| 523 | $this->addUsers($user); |
||
| 524 | } |
||
| 525 | } |
||
| 526 | |||
| 527 | public function addUsers(CourseRelUser $courseRelUser) |
||
| 528 | { |
||
| 529 | $courseRelUser->setCourse($this); |
||
| 530 | |||
| 531 | if (!$this->hasSubscription($courseRelUser)) { |
||
| 532 | $this->users[] = $courseRelUser; |
||
| 533 | } |
||
| 534 | } |
||
| 535 | |||
| 536 | /** |
||
| 537 | * @return bool |
||
| 538 | */ |
||
| 539 | public function hasUser(User $user) |
||
| 540 | { |
||
| 541 | $criteria = Criteria::create()->where( |
||
| 542 | Criteria::expr()->eq('user', $user) |
||
| 543 | ); |
||
| 544 | |||
| 545 | return $this->getUsers()->matching($criteria)->count() > 0; |
||
| 546 | } |
||
| 547 | |||
| 548 | /** |
||
| 549 | * @return bool |
||
| 550 | */ |
||
| 551 | public function hasStudent(User $user) |
||
| 552 | { |
||
| 553 | $criteria = Criteria::create()->where( |
||
| 554 | Criteria::expr()->eq('user', $user) |
||
| 555 | ); |
||
| 556 | |||
| 557 | return $this->getStudents()->matching($criteria)->count() > 0; |
||
| 558 | } |
||
| 559 | |||
| 560 | /** |
||
| 561 | * @return bool |
||
| 562 | */ |
||
| 563 | public function hasTeacher(User $user) |
||
| 564 | { |
||
| 565 | $criteria = Criteria::create()->where( |
||
| 566 | Criteria::expr()->eq('user', $user) |
||
| 567 | ); |
||
| 568 | |||
| 569 | return $this->getTeachers()->matching($criteria)->count() > 0; |
||
| 570 | } |
||
| 571 | |||
| 572 | /** |
||
| 573 | * @return bool |
||
| 574 | */ |
||
| 575 | public function hasGroup(CGroup $group) |
||
| 576 | { |
||
| 577 | /*$criteria = Criteria::create()->where( |
||
| 578 | Criteria::expr()->eq('groups', $group) |
||
| 579 | );*/ |
||
| 580 | |||
| 581 | return $this->getGroups()->contains($group); |
||
| 582 | } |
||
| 583 | |||
| 584 | /** |
||
| 585 | * Remove $user. |
||
| 586 | */ |
||
| 587 | public function removeUsers(CourseRelUser $user) |
||
| 588 | { |
||
| 589 | foreach ($this->users as $key => $value) { |
||
| 590 | if ($value->getId() == $user->getId()) { |
||
| 591 | unset($this->users[$key]); |
||
| 592 | } |
||
| 593 | } |
||
| 594 | } |
||
| 595 | |||
| 596 | public function addTeacher(User $user) |
||
| 597 | { |
||
| 598 | $this->addUser($user, 0, 'Trainer', User::COURSE_MANAGER); |
||
| 599 | } |
||
| 600 | |||
| 601 | public function addStudent(User $user) |
||
| 602 | { |
||
| 603 | $this->addUser($user, 0, '', User::STUDENT); |
||
| 604 | } |
||
| 605 | |||
| 606 | /** |
||
| 607 | * Set id. |
||
| 608 | * |
||
| 609 | * @return int |
||
| 610 | */ |
||
| 611 | public function setId($id) |
||
| 612 | { |
||
| 613 | $this->id = $id; |
||
| 614 | } |
||
| 615 | |||
| 616 | /** |
||
| 617 | * Get id. |
||
| 618 | * |
||
| 619 | * @return int |
||
| 620 | */ |
||
| 621 | public function getId() |
||
| 622 | { |
||
| 623 | return $this->id; |
||
| 624 | } |
||
| 625 | |||
| 626 | /** |
||
| 627 | * Set code. |
||
| 628 | * |
||
| 629 | * @param string $code |
||
| 630 | * |
||
| 631 | * @return Course |
||
| 632 | */ |
||
| 633 | public function setCode($code) |
||
| 634 | { |
||
| 635 | $this->code = $code; |
||
| 636 | $this->visualCode = $code; |
||
| 637 | $this->directory = $code; |
||
| 638 | |||
| 639 | return $this; |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * Get code. |
||
| 644 | * |
||
| 645 | * @return string |
||
| 646 | */ |
||
| 647 | public function getCode() |
||
| 648 | { |
||
| 649 | return $this->code; |
||
| 650 | } |
||
| 651 | |||
| 652 | /** |
||
| 653 | * Set directory. |
||
| 654 | * |
||
| 655 | * @param string $directory |
||
| 656 | * |
||
| 657 | * @return Course |
||
| 658 | */ |
||
| 659 | public function setDirectory($directory) |
||
| 660 | { |
||
| 661 | $this->directory = $directory; |
||
| 662 | |||
| 663 | return $this; |
||
| 664 | } |
||
| 665 | |||
| 666 | /** |
||
| 667 | * Get directory. |
||
| 668 | * |
||
| 669 | * @return string |
||
| 670 | */ |
||
| 671 | public function getDirectory() |
||
| 672 | { |
||
| 673 | return $this->directory; |
||
| 674 | } |
||
| 675 | |||
| 676 | /** |
||
| 677 | * Set courseLanguage. |
||
| 678 | * |
||
| 679 | * @param string $courseLanguage |
||
| 680 | * |
||
| 681 | * @return Course |
||
| 682 | */ |
||
| 683 | public function setCourseLanguage($courseLanguage) |
||
| 684 | { |
||
| 685 | $this->courseLanguage = $courseLanguage; |
||
| 686 | |||
| 687 | return $this; |
||
| 688 | } |
||
| 689 | |||
| 690 | /** |
||
| 691 | * Get courseLanguage. |
||
| 692 | * |
||
| 693 | * @return string |
||
| 694 | */ |
||
| 695 | public function getCourseLanguage() |
||
| 696 | { |
||
| 697 | return $this->courseLanguage; |
||
| 698 | } |
||
| 699 | |||
| 700 | /** |
||
| 701 | * Set title. |
||
| 702 | * |
||
| 703 | * @param string $title |
||
| 704 | * |
||
| 705 | * @return Course |
||
| 706 | */ |
||
| 707 | public function setTitle($title) |
||
| 708 | { |
||
| 709 | $this->title = $title; |
||
| 710 | |||
| 711 | return $this; |
||
| 712 | } |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Get title. |
||
| 716 | * |
||
| 717 | * @return string |
||
| 718 | */ |
||
| 719 | public function getTitle() |
||
| 720 | { |
||
| 721 | return (string) $this->title; |
||
| 722 | } |
||
| 723 | |||
| 724 | public function getName() |
||
| 725 | { |
||
| 726 | return $this->getTitle(); |
||
| 727 | } |
||
| 728 | |||
| 729 | /** |
||
| 730 | * @return string |
||
| 731 | */ |
||
| 732 | public function getTitleAndCode() |
||
| 733 | { |
||
| 734 | return $this->getTitle().' ('.$this->getCode().')'; |
||
| 735 | } |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Set description. |
||
| 739 | * |
||
| 740 | * @param string $description |
||
| 741 | * |
||
| 742 | * @return Course |
||
| 743 | */ |
||
| 744 | public function setDescription($description) |
||
| 745 | { |
||
| 746 | $this->description = $description; |
||
| 747 | |||
| 748 | return $this; |
||
| 749 | } |
||
| 750 | |||
| 751 | /** |
||
| 752 | * Get description. |
||
| 753 | * |
||
| 754 | * @return string |
||
| 755 | */ |
||
| 756 | public function getDescription() |
||
| 757 | { |
||
| 758 | return $this->description; |
||
| 759 | } |
||
| 760 | |||
| 761 | /** |
||
| 762 | * Set category. |
||
| 763 | * |
||
| 764 | * @param ArrayCollection $categories |
||
| 765 | * |
||
| 766 | * @return Course |
||
| 767 | */ |
||
| 768 | public function setCategories(ArrayCollection $categories): self |
||
| 769 | { |
||
| 770 | $this->categories = $categories; |
||
| 771 | |||
| 772 | return $this; |
||
| 773 | } |
||
| 774 | |||
| 775 | public function getCategories() |
||
| 776 | { |
||
| 777 | return $this->categories; |
||
| 778 | } |
||
| 779 | |||
| 780 | public function addCategory(CourseCategory $category): self |
||
| 781 | { |
||
| 782 | $this->categories[] = $category; |
||
| 783 | |||
| 784 | return $this; |
||
| 785 | } |
||
| 786 | |||
| 787 | public function removeCategory(CourseCategory $category) |
||
| 788 | { |
||
| 789 | $this->categories->removeElement($category); |
||
| 790 | } |
||
| 791 | |||
| 792 | /** |
||
| 793 | * Set visibility. |
||
| 794 | * |
||
| 795 | * @param int $visibility |
||
| 796 | * |
||
| 797 | * @return Course |
||
| 798 | */ |
||
| 799 | public function setVisibility($visibility) |
||
| 800 | { |
||
| 801 | $this->visibility = $visibility; |
||
| 802 | |||
| 803 | return $this; |
||
| 804 | } |
||
| 805 | |||
| 806 | /** |
||
| 807 | * Get visibility. |
||
| 808 | * |
||
| 809 | * @return int |
||
| 810 | */ |
||
| 811 | public function getVisibility() |
||
| 812 | { |
||
| 813 | return (int) $this->visibility; |
||
| 814 | } |
||
| 815 | |||
| 816 | /** |
||
| 817 | * Set showScore. |
||
| 818 | * |
||
| 819 | * @param int $showScore |
||
| 820 | * |
||
| 821 | * @return Course |
||
| 822 | */ |
||
| 823 | public function setShowScore($showScore) |
||
| 824 | { |
||
| 825 | $this->showScore = $showScore; |
||
| 826 | |||
| 827 | return $this; |
||
| 828 | } |
||
| 829 | |||
| 830 | /** |
||
| 831 | * Get showScore. |
||
| 832 | * |
||
| 833 | * @return int |
||
| 834 | */ |
||
| 835 | public function getShowScore() |
||
| 836 | { |
||
| 837 | return $this->showScore; |
||
| 838 | } |
||
| 839 | |||
| 840 | /** |
||
| 841 | * Set tutorName. |
||
| 842 | * |
||
| 843 | * @param string $tutorName |
||
| 844 | * |
||
| 845 | * @return Course |
||
| 846 | */ |
||
| 847 | public function setTutorName($tutorName) |
||
| 848 | { |
||
| 849 | $this->tutorName = $tutorName; |
||
| 850 | |||
| 851 | return $this; |
||
| 852 | } |
||
| 853 | |||
| 854 | /** |
||
| 855 | * Get tutorName. |
||
| 856 | * |
||
| 857 | * @return string |
||
| 858 | */ |
||
| 859 | public function getTutorName() |
||
| 860 | { |
||
| 861 | return $this->tutorName; |
||
| 862 | } |
||
| 863 | |||
| 864 | /** |
||
| 865 | * Set visualCode. |
||
| 866 | * |
||
| 867 | * @param string $visualCode |
||
| 868 | * |
||
| 869 | * @return Course |
||
| 870 | */ |
||
| 871 | public function setVisualCode($visualCode) |
||
| 872 | { |
||
| 873 | $this->visualCode = $visualCode; |
||
| 874 | |||
| 875 | return $this; |
||
| 876 | } |
||
| 877 | |||
| 878 | /** |
||
| 879 | * Get visualCode. |
||
| 880 | * |
||
| 881 | * @return string |
||
| 882 | */ |
||
| 883 | public function getVisualCode() |
||
| 884 | { |
||
| 885 | return $this->visualCode; |
||
| 886 | } |
||
| 887 | |||
| 888 | /** |
||
| 889 | * Set departmentName. |
||
| 890 | * |
||
| 891 | * @param string $departmentName |
||
| 892 | * |
||
| 893 | * @return Course |
||
| 894 | */ |
||
| 895 | public function setDepartmentName($departmentName) |
||
| 896 | { |
||
| 897 | $this->departmentName = $departmentName; |
||
| 898 | |||
| 899 | return $this; |
||
| 900 | } |
||
| 901 | |||
| 902 | /** |
||
| 903 | * Get departmentName. |
||
| 904 | * |
||
| 905 | * @return string |
||
| 906 | */ |
||
| 907 | public function getDepartmentName() |
||
| 908 | { |
||
| 909 | return $this->departmentName; |
||
| 910 | } |
||
| 911 | |||
| 912 | /** |
||
| 913 | * Set departmentUrl. |
||
| 914 | * |
||
| 915 | * @param string $departmentUrl |
||
| 916 | * |
||
| 917 | * @return Course |
||
| 918 | */ |
||
| 919 | public function setDepartmentUrl($departmentUrl) |
||
| 920 | { |
||
| 921 | $this->departmentUrl = $departmentUrl; |
||
| 922 | |||
| 923 | return $this; |
||
| 924 | } |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Get departmentUrl. |
||
| 928 | * |
||
| 929 | * @return string |
||
| 930 | */ |
||
| 931 | public function getDepartmentUrl() |
||
| 934 | } |
||
| 935 | |||
| 936 | /** |
||
| 937 | * Set diskQuota. |
||
| 938 | * |
||
| 939 | * @param int $diskQuota |
||
| 940 | * |
||
| 941 | * @return Course |
||
| 942 | */ |
||
| 943 | public function setDiskQuota($diskQuota) |
||
| 944 | { |
||
| 945 | $this->diskQuota = (int) $diskQuota; |
||
| 946 | |||
| 947 | return $this; |
||
| 948 | } |
||
| 949 | |||
| 950 | /** |
||
| 951 | * Get diskQuota. |
||
| 952 | * |
||
| 953 | * @return int |
||
| 954 | */ |
||
| 955 | public function getDiskQuota() |
||
| 956 | { |
||
| 957 | return $this->diskQuota; |
||
| 958 | } |
||
| 959 | |||
| 960 | /** |
||
| 961 | * Set lastVisit. |
||
| 962 | * |
||
| 963 | * @param \DateTime $lastVisit |
||
| 964 | * |
||
| 965 | * @return Course |
||
| 966 | */ |
||
| 967 | public function setLastVisit($lastVisit) |
||
| 968 | { |
||
| 969 | $this->lastVisit = $lastVisit; |
||
| 970 | |||
| 971 | return $this; |
||
| 972 | } |
||
| 973 | |||
| 974 | /** |
||
| 975 | * Get lastVisit. |
||
| 976 | * |
||
| 977 | * @return \DateTime |
||
| 978 | */ |
||
| 979 | public function getLastVisit() |
||
| 980 | { |
||
| 981 | return $this->lastVisit; |
||
| 982 | } |
||
| 983 | |||
| 984 | /** |
||
| 985 | * Set lastEdit. |
||
| 986 | * |
||
| 987 | * @param \DateTime $lastEdit |
||
| 988 | * |
||
| 989 | * @return Course |
||
| 990 | */ |
||
| 991 | public function setLastEdit($lastEdit) |
||
| 992 | { |
||
| 993 | $this->lastEdit = $lastEdit; |
||
| 994 | |||
| 995 | return $this; |
||
| 996 | } |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Get lastEdit. |
||
| 1000 | * |
||
| 1001 | * @return \DateTime |
||
| 1002 | */ |
||
| 1003 | public function getLastEdit() |
||
| 1004 | { |
||
| 1005 | return $this->lastEdit; |
||
| 1006 | } |
||
| 1007 | |||
| 1008 | /** |
||
| 1009 | * Set creationDate. |
||
| 1010 | * |
||
| 1011 | * @param \DateTime $creationDate |
||
| 1012 | * |
||
| 1013 | * @return Course |
||
| 1014 | */ |
||
| 1015 | public function setCreationDate($creationDate) |
||
| 1016 | { |
||
| 1017 | $this->creationDate = $creationDate; |
||
| 1018 | |||
| 1019 | return $this; |
||
| 1020 | } |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * Get creationDate. |
||
| 1024 | * |
||
| 1025 | * @return \DateTime |
||
| 1026 | */ |
||
| 1027 | public function getCreationDate() |
||
| 1028 | { |
||
| 1029 | return $this->creationDate; |
||
| 1030 | } |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Set expirationDate. |
||
| 1034 | * |
||
| 1035 | * @param \DateTime $expirationDate |
||
| 1036 | * |
||
| 1037 | * @return Course |
||
| 1038 | */ |
||
| 1039 | public function setExpirationDate($expirationDate) |
||
| 1040 | { |
||
| 1041 | $this->expirationDate = $expirationDate; |
||
| 1042 | |||
| 1043 | return $this; |
||
| 1044 | } |
||
| 1045 | |||
| 1046 | /** |
||
| 1047 | * Get expirationDate. |
||
| 1048 | * |
||
| 1049 | * @return \DateTime |
||
| 1050 | */ |
||
| 1051 | public function getExpirationDate() |
||
| 1052 | { |
||
| 1053 | return $this->expirationDate; |
||
| 1054 | } |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * Set subscribe. |
||
| 1058 | * |
||
| 1059 | * @param bool $subscribe |
||
| 1060 | * |
||
| 1061 | * @return Course |
||
| 1062 | */ |
||
| 1063 | public function setSubscribe($subscribe) |
||
| 1064 | { |
||
| 1065 | $this->subscribe = (bool) $subscribe; |
||
| 1066 | |||
| 1067 | return $this; |
||
| 1068 | } |
||
| 1069 | |||
| 1070 | /** |
||
| 1071 | * Get subscribe. |
||
| 1072 | * |
||
| 1073 | * @return bool |
||
| 1074 | */ |
||
| 1075 | public function getSubscribe() |
||
| 1076 | { |
||
| 1077 | return $this->subscribe; |
||
| 1078 | } |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Set unsubscribe. |
||
| 1082 | * |
||
| 1083 | * @param bool $unsubscribe |
||
| 1084 | * |
||
| 1085 | * @return Course |
||
| 1086 | */ |
||
| 1087 | public function setUnsubscribe($unsubscribe) |
||
| 1088 | { |
||
| 1089 | $this->unsubscribe = (bool) $unsubscribe; |
||
| 1090 | |||
| 1091 | return $this; |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | /** |
||
| 1095 | * Get unsubscribe. |
||
| 1096 | * |
||
| 1097 | * @return bool |
||
| 1098 | */ |
||
| 1099 | public function getUnsubscribe() |
||
| 1100 | { |
||
| 1101 | return $this->unsubscribe; |
||
| 1102 | } |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Set registrationCode. |
||
| 1106 | * |
||
| 1107 | * @param string $registrationCode |
||
| 1108 | * |
||
| 1109 | * @return Course |
||
| 1110 | */ |
||
| 1111 | public function setRegistrationCode($registrationCode) |
||
| 1112 | { |
||
| 1113 | $this->registrationCode = $registrationCode; |
||
| 1114 | |||
| 1115 | return $this; |
||
| 1116 | } |
||
| 1117 | |||
| 1118 | /** |
||
| 1119 | * Get registrationCode. |
||
| 1120 | * |
||
| 1121 | * @return string |
||
| 1122 | */ |
||
| 1123 | public function getRegistrationCode() |
||
| 1124 | { |
||
| 1125 | return $this->registrationCode; |
||
| 1126 | } |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Set legal. |
||
| 1130 | * |
||
| 1131 | * @param string $legal |
||
| 1132 | * |
||
| 1133 | * @return Course |
||
| 1134 | */ |
||
| 1135 | public function setLegal($legal) |
||
| 1136 | { |
||
| 1137 | $this->legal = $legal; |
||
| 1138 | |||
| 1139 | return $this; |
||
| 1140 | } |
||
| 1141 | |||
| 1142 | /** |
||
| 1143 | * Get legal. |
||
| 1144 | * |
||
| 1145 | * @return string |
||
| 1146 | */ |
||
| 1147 | public function getLegal() |
||
| 1148 | { |
||
| 1149 | return $this->legal; |
||
| 1150 | } |
||
| 1151 | |||
| 1152 | /** |
||
| 1153 | * Set activateLegal. |
||
| 1154 | * |
||
| 1155 | * @param int $activateLegal |
||
| 1156 | * |
||
| 1157 | * @return Course |
||
| 1158 | */ |
||
| 1159 | public function setActivateLegal($activateLegal) |
||
| 1160 | { |
||
| 1161 | $this->activateLegal = $activateLegal; |
||
| 1162 | |||
| 1163 | return $this; |
||
| 1164 | } |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Get activateLegal. |
||
| 1168 | * |
||
| 1169 | * @return int |
||
| 1170 | */ |
||
| 1171 | public function getActivateLegal() |
||
| 1172 | { |
||
| 1173 | return $this->activateLegal; |
||
| 1174 | } |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * @return bool |
||
| 1178 | */ |
||
| 1179 | public function isAddTeachersToSessionsCourses() |
||
| 1180 | { |
||
| 1181 | return $this->addTeachersToSessionsCourses; |
||
| 1182 | } |
||
| 1183 | |||
| 1184 | /** |
||
| 1185 | * @param bool $addTeachersToSessionsCourses |
||
| 1186 | */ |
||
| 1187 | public function setAddTeachersToSessionsCourses($addTeachersToSessionsCourses): self |
||
| 1188 | { |
||
| 1189 | $this->addTeachersToSessionsCourses = $addTeachersToSessionsCourses; |
||
| 1190 | |||
| 1191 | return $this; |
||
| 1192 | } |
||
| 1193 | |||
| 1194 | /** |
||
| 1195 | * Set courseTypeId. |
||
| 1196 | * |
||
| 1197 | * @param int $courseTypeId |
||
| 1198 | * |
||
| 1199 | * @return Course |
||
| 1200 | */ |
||
| 1201 | public function setCourseTypeId($courseTypeId) |
||
| 1202 | { |
||
| 1203 | $this->courseTypeId = $courseTypeId; |
||
| 1204 | |||
| 1205 | return $this; |
||
| 1206 | } |
||
| 1207 | |||
| 1208 | /** |
||
| 1209 | * Get courseTypeId. |
||
| 1210 | * |
||
| 1211 | * @return int |
||
| 1212 | */ |
||
| 1213 | public function getCourseTypeId() |
||
| 1214 | { |
||
| 1215 | return $this->courseTypeId; |
||
| 1216 | } |
||
| 1217 | |||
| 1218 | /** |
||
| 1219 | * @return Room |
||
| 1220 | */ |
||
| 1221 | public function getRoom() |
||
| 1222 | { |
||
| 1223 | return $this->room; |
||
| 1224 | } |
||
| 1225 | |||
| 1226 | /** |
||
| 1227 | * @param Room $room |
||
| 1228 | * |
||
| 1229 | * @return Course |
||
| 1230 | */ |
||
| 1231 | public function setRoom($room) |
||
| 1232 | { |
||
| 1233 | $this->room = $room; |
||
| 1234 | |||
| 1235 | return $this; |
||
| 1236 | } |
||
| 1237 | |||
| 1238 | /** |
||
| 1239 | * @return bool |
||
| 1240 | */ |
||
| 1241 | public function isActive() |
||
| 1242 | { |
||
| 1243 | $activeVisibilityList = [ |
||
| 1244 | self::REGISTERED, |
||
| 1245 | self::OPEN_PLATFORM, |
||
| 1246 | self::OPEN_WORLD, |
||
| 1247 | ]; |
||
| 1248 | |||
| 1249 | return in_array($this->visibility, $activeVisibilityList); |
||
| 1250 | } |
||
| 1251 | |||
| 1252 | /** |
||
| 1253 | * Anybody can see this course. |
||
| 1254 | */ |
||
| 1255 | public function isPublic(): bool |
||
| 1256 | { |
||
| 1257 | return self::OPEN_WORLD === $this->visibility; |
||
| 1258 | } |
||
| 1259 | |||
| 1260 | public function isHidden(): bool |
||
| 1261 | { |
||
| 1262 | return self::HIDDEN === $this->visibility; |
||
| 1263 | } |
||
| 1264 | |||
| 1265 | /** |
||
| 1266 | * @return array |
||
| 1267 | */ |
||
| 1268 | public static function getStatusList() |
||
| 1269 | { |
||
| 1270 | return [ |
||
| 1271 | self::CLOSED => 'Closed', |
||
| 1272 | self::REGISTERED => 'Registered', |
||
| 1273 | self::OPEN_PLATFORM => 'Open platform', |
||
| 1274 | self::OPEN_WORLD => 'Open world', |
||
| 1275 | self::HIDDEN => 'Hidden', |
||
| 1276 | ]; |
||
| 1277 | } |
||
| 1278 | |||
| 1279 | /** |
||
| 1280 | * @return Session |
||
| 1281 | */ |
||
| 1282 | public function getCurrentSession() |
||
| 1285 | } |
||
| 1286 | |||
| 1287 | /** |
||
| 1288 | * @return $this |
||
| 1289 | */ |
||
| 1290 | public function setCurrentSession(Session $session) |
||
| 1291 | { |
||
| 1292 | // If the session is registered in the course session list. |
||
| 1293 | /*if ($this->getSessions()->contains($session->getId())) { |
||
| 1294 | $this->currentSession = $session; |
||
| 1295 | }*/ |
||
| 1296 | |||
| 1297 | $list = $this->getSessions(); |
||
| 1298 | /** @var SessionRelCourse $item */ |
||
| 1299 | foreach ($list as $item) { |
||
| 1300 | if ($item->getSession()->getId() == $session->getId()) { |
||
| 1301 | $this->currentSession = $session; |
||
| 1302 | |||
| 1303 | break; |
||
| 1304 | } |
||
| 1305 | } |
||
| 1306 | |||
| 1307 | return $this; |
||
| 1308 | } |
||
| 1309 | |||
| 1310 | /** |
||
| 1311 | * @return $this |
||
| 1312 | */ |
||
| 1313 | public function setCurrentUrl(AccessUrl $url) |
||
| 1314 | { |
||
| 1315 | $urlList = $this->getUrls(); |
||
| 1316 | /** @var AccessUrlRelCourse $item */ |
||
| 1317 | foreach ($urlList as $item) { |
||
| 1318 | if ($item->getUrl()->getId() == $url->getId()) { |
||
| 1319 | $this->currentUrl = $url; |
||
| 1320 | |||
| 1321 | break; |
||
| 1322 | } |
||
| 1323 | } |
||
| 1324 | |||
| 1325 | return $this; |
||
| 1326 | } |
||
| 1327 | |||
| 1328 | /** |
||
| 1329 | * @return AccessUrl |
||
| 1330 | */ |
||
| 1331 | public function getCurrentUrl() |
||
| 1332 | { |
||
| 1333 | return $this->currentUrl; |
||
| 1334 | } |
||
| 1335 | |||
| 1336 | /** |
||
| 1337 | * Get issuedSkills. |
||
| 1338 | * |
||
| 1339 | * @return ArrayCollection |
||
| 1340 | */ |
||
| 1341 | public function getIssuedSkills() |
||
| 1342 | { |
||
| 1343 | return $this->issuedSkills; |
||
| 1344 | } |
||
| 1345 | |||
| 1346 | /** |
||
| 1347 | * @return bool |
||
| 1348 | */ |
||
| 1349 | public function hasSubscription(CourseRelUser $subscription) |
||
| 1366 | } |
||
| 1367 | |||
| 1368 | /** |
||
| 1369 | * @param string $relationType |
||
| 1370 | * @param string $role |
||
| 1371 | * @param string $status |
||
| 1372 | */ |
||
| 1373 | public function addUser(User $user, $relationType, $role, $status) |
||
| 1374 | { |
||
| 1375 | $courseRelUser = new CourseRelUser(); |
||
| 1376 | $courseRelUser->setCourse($this); |
||
| 1377 | $courseRelUser->setUser($user); |
||
| 1378 | $courseRelUser->setRelationType($relationType); |
||
| 1379 | //$courseRelUser->setRole($role); |
||
| 1380 | $courseRelUser->setStatus($status); |
||
| 1381 | $this->addUsers($courseRelUser); |
||
| 1382 | } |
||
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Resource identifier. |
||
| 1386 | */ |
||
| 1387 | public function getResourceIdentifier(): int |
||
| 1388 | { |
||
| 1389 | return $this->getId(); |
||
| 1390 | } |
||
| 1391 | |||
| 1392 | public function getResourceName(): string |
||
| 1395 | } |
||
| 1396 | |||
| 1397 | public function setResourceName(string $name): self |
||
| 1398 | { |
||
| 1399 | return $this->setCode($name); |
||
| 1400 | } |
||
| 1401 | } |
||
| 1402 |