| Total Complexity | 132 |
| Total Lines | 1211 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| 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 |
||
| 36 | #[ApiResource( |
||
| 37 | types: ['https://schema.org/Course'], |
||
| 38 | operations: [ |
||
| 39 | new Get(security: "is_granted('VIEW', object)"), |
||
| 40 | new Get( |
||
| 41 | uriTemplate: '/courses/{id}/stats/{metric}', |
||
| 42 | requirements: [ |
||
| 43 | 'id' => '\d+', |
||
| 44 | 'metric' => 'course-avg-score|course-avg-progress', |
||
| 45 | ], |
||
| 46 | controller: GetCourseStatsAction::class, |
||
| 47 | openapiContext: [ |
||
| 48 | 'summary' => 'Course-wide statistics, switched by {metric}', |
||
| 49 | 'parameters' => [ |
||
| 50 | [ |
||
| 51 | 'name' => 'metric', |
||
| 52 | 'in' => 'path', |
||
| 53 | 'required' => true, |
||
| 54 | 'schema' => [ |
||
| 55 | 'type' => 'string', |
||
| 56 | 'enum' => ['course-avg-score', 'course-avg-progress'], |
||
| 57 | ], |
||
| 58 | 'description' => 'Metric selector', |
||
| 59 | ], |
||
| 60 | [ |
||
| 61 | 'name' => 'sessionId', |
||
| 62 | 'in' => 'query', |
||
| 63 | 'required' => false, |
||
| 64 | 'schema' => ['type' => 'integer'], |
||
| 65 | 'description' => 'Optional Session ID', |
||
| 66 | ], |
||
| 67 | ], |
||
| 68 | ], |
||
| 69 | read: false, |
||
| 70 | deserialize: false, |
||
| 71 | ), |
||
| 72 | new Post(security: "is_granted('ROLE_USER')"), |
||
| 73 | new GetCollection(security: "is_granted('ROLE_USER')"), |
||
| 74 | new GetCollection( |
||
| 75 | uriTemplate: '/public_courses', |
||
| 76 | normalizationContext: ['groups' => ['course:read']], |
||
| 77 | provider: PublicCatalogueCourseStateProvider::class |
||
| 78 | ), |
||
| 79 | ], |
||
| 80 | normalizationContext: ['groups' => ['course:read']], |
||
| 81 | denormalizationContext: ['groups' => ['course:write']], |
||
| 82 | filters: ['course.sticky_boolean_filter'], |
||
| 83 | paginationClientEnabled: true |
||
| 84 | )] |
||
| 85 | #[ORM\Table(name: 'course')] |
||
| 86 | #[ORM\Index(columns: ['sticky'], name: 'idx_course_sticky')] |
||
| 87 | #[UniqueEntity('code')] |
||
| 88 | #[UniqueEntity('visualCode')] |
||
| 89 | #[ORM\Entity(repositoryClass: CourseRepository::class)] |
||
| 90 | #[ORM\EntityListeners([ResourceListener::class, CourseListener::class])] |
||
| 91 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial', 'code' => 'partial'])] |
||
| 92 | #[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'title'])] |
||
| 93 | class Course extends AbstractResource implements ResourceInterface, ResourceWithAccessUrlInterface, ResourceIllustrationInterface, ExtraFieldItemInterface, Stringable |
||
| 94 | { |
||
| 95 | public const CLOSED = 0; |
||
| 96 | public const REGISTERED = 1; |
||
| 97 | // Only registered users in the course. |
||
| 98 | public const OPEN_PLATFORM = 2; |
||
| 99 | // All users registered in the platform (default). |
||
| 100 | public const OPEN_WORLD = 3; |
||
| 101 | public const HIDDEN = 4; |
||
| 102 | |||
| 103 | #[Groups([ |
||
| 104 | 'course:read', |
||
| 105 | 'course_rel_user:read', |
||
| 106 | 'session:read', |
||
| 107 | 'session_rel_course_rel_user:read', |
||
| 108 | 'session_rel_user:read', |
||
| 109 | 'session_rel_course:read', |
||
| 110 | 'track_e_exercise:read', |
||
| 111 | 'user_subscriptions:sessions', |
||
| 112 | ])] |
||
| 113 | #[ORM\Column(name: 'id', type: 'integer')] |
||
| 114 | #[ORM\Id] |
||
| 115 | #[ORM\GeneratedValue(strategy: 'AUTO')] |
||
| 116 | protected ?int $id = null; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * The course title. |
||
| 120 | */ |
||
| 121 | #[Groups([ |
||
| 122 | 'course:read', |
||
| 123 | 'course:write', |
||
| 124 | 'course_rel_user:read', |
||
| 125 | 'session:read', |
||
| 126 | 'session_rel_course_rel_user:read', |
||
| 127 | 'session_rel_user:read', |
||
| 128 | 'session_rel_course:read', |
||
| 129 | 'track_e_exercise:read', |
||
| 130 | 'user_subscriptions:sessions', |
||
| 131 | ])] |
||
| 132 | #[Assert\NotBlank(message: 'A Course requires a title')] |
||
| 133 | #[ORM\Column(name: 'title', type: 'string', length: 250, unique: false, nullable: true)] |
||
| 134 | protected ?string $title = null; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * The course code. |
||
| 138 | */ |
||
| 139 | #[ApiProperty(iris: ['http://schema.org/courseCode'])] |
||
| 140 | #[Groups(['course:read', 'user:write', 'course_rel_user:read'])] |
||
| 141 | #[Assert\NotBlank] |
||
| 142 | #[Assert\Length(max: 40, maxMessage: 'Code cannot be longer than {{ limit }} characters')] |
||
| 143 | #[Gedmo\Slug(fields: ['title'], updatable: false, style: 'upper', unique: true, separator: '')] |
||
| 144 | #[ORM\Column(name: 'code', type: 'string', length: 40, unique: true, nullable: false)] |
||
| 145 | protected string $code; |
||
| 146 | |||
| 147 | #[Assert\Length(max: 40, maxMessage: 'Code cannot be longer than {{ limit }} characters')] |
||
| 148 | #[ORM\Column(name: 'visual_code', type: 'string', length: 40, unique: false, nullable: true)] |
||
| 149 | protected ?string $visualCode = null; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @var Collection<int, CourseRelUser> |
||
| 153 | */ |
||
| 154 | #[Groups([ |
||
| 155 | 'course:read', |
||
| 156 | 'user:read', |
||
| 157 | 'course_rel_user:read', |
||
| 158 | ])] |
||
| 159 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: CourseRelUser::class, cascade: ['persist'], orphanRemoval: true)] |
||
| 160 | protected Collection $users; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @var Collection<int, EntityAccessUrlInterface> |
||
| 164 | */ |
||
| 165 | #[ORM\OneToMany( |
||
| 166 | mappedBy: 'course', |
||
| 167 | targetEntity: AccessUrlRelCourse::class, |
||
| 168 | cascade: ['persist', 'remove'], |
||
| 169 | orphanRemoval: true |
||
| 170 | )] |
||
| 171 | protected Collection $urls; |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @var Collection<int, SessionRelCourse> |
||
| 175 | */ |
||
| 176 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: SessionRelCourse::class, cascade: ['persist', 'remove'])] |
||
| 177 | protected Collection $sessions; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @var Collection<int, SessionRelCourseRelUser> |
||
| 181 | */ |
||
| 182 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: SessionRelCourseRelUser::class, cascade: [ |
||
| 183 | 'persist', |
||
| 184 | 'remove', |
||
| 185 | ])] |
||
| 186 | protected Collection $sessionRelCourseRelUsers; |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @var Collection<int, CTool> |
||
| 190 | */ |
||
| 191 | #[ORM\OneToMany( |
||
| 192 | mappedBy: 'course', |
||
| 193 | targetEntity: CTool::class, |
||
| 194 | cascade: [ |
||
| 195 | 'persist', |
||
| 196 | 'remove', |
||
| 197 | ], |
||
| 198 | orphanRemoval: true |
||
| 199 | )] |
||
| 200 | protected Collection $tools; |
||
| 201 | |||
| 202 | protected Session $currentSession; |
||
| 203 | |||
| 204 | protected AccessUrl $currentUrl; |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @var Collection<int, SkillRelCourse> |
||
| 208 | */ |
||
| 209 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: SkillRelCourse::class, cascade: ['persist', 'remove'])] |
||
| 210 | protected Collection $skills; |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @var Collection<int, SkillRelUser> |
||
| 214 | */ |
||
| 215 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: SkillRelUser::class, cascade: ['persist', 'remove'])] |
||
| 216 | protected Collection $issuedSkills; |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @var Collection<int, GradebookCategory> |
||
| 220 | */ |
||
| 221 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: GradebookCategory::class, cascade: ['persist', 'remove'])] |
||
| 222 | protected Collection $gradebookCategories; |
||
| 223 | |||
| 224 | /** |
||
| 225 | * @var Collection<int, GradebookEvaluation> |
||
| 226 | */ |
||
| 227 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: GradebookEvaluation::class, cascade: ['persist', 'remove'])] |
||
| 228 | protected Collection $gradebookEvaluations; |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @var Collection<int, GradebookLink> |
||
| 232 | */ |
||
| 233 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: GradebookLink::class, cascade: ['persist', 'remove'])] |
||
| 234 | protected Collection $gradebookLinks; |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @var Collection<int, TrackEHotspot> |
||
| 238 | */ |
||
| 239 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: TrackEHotspot::class, cascade: ['persist', 'remove'])] |
||
| 240 | protected Collection $trackEHotspots; |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @var Collection<int, SearchEngineRef> |
||
| 244 | */ |
||
| 245 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: SearchEngineRef::class, cascade: ['persist', 'remove'])] |
||
| 246 | protected Collection $searchEngineRefs; |
||
| 247 | |||
| 248 | /** |
||
| 249 | * @var Collection<int, Templates> |
||
| 250 | */ |
||
| 251 | #[ORM\OneToMany(mappedBy: 'course', targetEntity: Templates::class, cascade: ['persist', 'remove'])] |
||
| 252 | protected Collection $templates; |
||
| 253 | |||
| 254 | /** |
||
| 255 | * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SpecificFieldValues", mappedBy="course"). |
||
| 256 | */ |
||
| 257 | // protected $specificFieldValues; |
||
| 258 | |||
| 259 | /** |
||
| 260 | * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SharedSurvey", mappedBy="course"). |
||
| 261 | */ |
||
| 262 | // protected $sharedSurveys; |
||
| 263 | |||
| 264 | #[ORM\Column(name: 'directory', type: 'string', length: 40, unique: false, nullable: true)] |
||
| 265 | protected ?string $directory = null; |
||
| 266 | |||
| 267 | #[Groups(['course:read', 'session:read'])] |
||
| 268 | #[Assert\NotBlank] |
||
| 269 | #[ORM\Column(name: 'course_language', type: 'string', length: 20, unique: false, nullable: false)] |
||
| 270 | protected string $courseLanguage; |
||
| 271 | |||
| 272 | #[Groups(['course:read', 'course_rel_user:read'])] |
||
| 273 | #[ORM\Column(name: 'description', type: 'text', unique: false, nullable: true)] |
||
| 274 | protected ?string $description; |
||
| 275 | |||
| 276 | #[Groups(['course:read', 'course_rel_user:read'])] |
||
| 277 | #[ORM\Column(name: 'introduction', type: 'text', nullable: true)] |
||
| 278 | protected ?string $introduction; |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @var Collection<int, CourseCategory> |
||
| 282 | */ |
||
| 283 | #[Groups(['course:read', 'course:write', 'course_rel_user:read', 'session:read'])] |
||
| 284 | #[ORM\JoinTable(name: 'course_rel_category')] |
||
| 285 | #[ORM\JoinColumn(name: 'course_id', referencedColumnName: 'id')] |
||
| 286 | #[ORM\InverseJoinColumn(name: 'course_category_id', referencedColumnName: 'id')] |
||
| 287 | #[ORM\ManyToMany(targetEntity: CourseCategory::class, inversedBy: 'courses')] |
||
| 288 | protected Collection $categories; |
||
| 289 | |||
| 290 | #[Assert\NotBlank] |
||
| 291 | #[Groups(['course:read', 'course:write'])] |
||
| 292 | #[ORM\Column(name: 'visibility', type: 'integer', unique: false, nullable: false)] |
||
| 293 | protected int $visibility; |
||
| 294 | |||
| 295 | #[ORM\Column(name: 'show_score', type: 'integer', unique: false, nullable: true)] |
||
| 296 | protected ?int $showScore = null; |
||
| 297 | |||
| 298 | #[ORM\Column(name: 'tutor_name', type: 'string', length: 200, unique: false, nullable: true)] |
||
| 299 | protected ?string $tutorName; |
||
| 300 | |||
| 301 | #[Groups(['course:read'])] |
||
| 302 | #[ORM\Column(name: 'department_name', type: 'string', length: 30, unique: false, nullable: true)] |
||
| 303 | protected ?string $departmentName = null; |
||
| 304 | |||
| 305 | #[Assert\Url] |
||
| 306 | #[Groups(['course:read', 'course:write'])] |
||
| 307 | #[ORM\Column(name: 'department_url', type: 'string', length: 180, unique: false, nullable: true)] |
||
| 308 | protected ?string $departmentUrl = null; |
||
| 309 | |||
| 310 | #[Assert\Url] |
||
| 311 | #[Groups(['course:read', 'course:write'])] |
||
| 312 | #[ORM\Column(name: 'video_url', type: 'string', length: 255)] |
||
| 313 | protected string $videoUrl; |
||
| 314 | |||
| 315 | #[Groups(['course:read', 'course:write'])] |
||
| 316 | #[ORM\Column(name: 'sticky', type: 'boolean')] |
||
| 317 | protected bool $sticky; |
||
| 318 | |||
| 319 | #[ORM\Column(name: 'disk_quota', type: 'integer', unique: false, nullable: true)] |
||
| 320 | protected ?int $diskQuota = null; |
||
| 321 | |||
| 322 | #[ORM\Column(name: 'last_visit', type: 'datetime', unique: false, nullable: true)] |
||
| 323 | protected ?DateTime $lastVisit; |
||
| 324 | |||
| 325 | #[ORM\Column(name: 'last_edit', type: 'datetime', unique: false, nullable: true)] |
||
| 326 | protected ?DateTime $lastEdit; |
||
| 327 | |||
| 328 | #[ORM\Column(name: 'creation_date', type: 'datetime', unique: false, nullable: false)] |
||
| 329 | protected DateTime $creationDate; |
||
| 330 | |||
| 331 | #[Groups(['course:read'])] |
||
| 332 | #[ORM\Column(name: 'expiration_date', type: 'datetime', unique: false, nullable: true)] |
||
| 333 | protected ?DateTime $expirationDate = null; |
||
| 334 | |||
| 335 | #[Assert\NotNull] |
||
| 336 | #[Groups(['course:read'])] |
||
| 337 | #[ORM\Column(name: 'subscribe', type: 'boolean', unique: false, nullable: false)] |
||
| 338 | protected bool $subscribe; |
||
| 339 | |||
| 340 | #[Assert\NotNull] |
||
| 341 | #[Groups(['course:read'])] |
||
| 342 | #[ORM\Column(name: 'unsubscribe', type: 'boolean', unique: false, nullable: false)] |
||
| 343 | protected bool $unsubscribe; |
||
| 344 | |||
| 345 | #[ORM\Column(name: 'registration_code', type: 'string', length: 255, unique: false, nullable: true)] |
||
| 346 | protected ?string $registrationCode; |
||
| 347 | |||
| 348 | #[ORM\Column(name: 'legal', type: 'text', unique: false, nullable: true)] |
||
| 349 | protected ?string $legal; |
||
| 350 | |||
| 351 | #[ORM\Column(name: 'activate_legal', type: 'integer', unique: false, nullable: true)] |
||
| 352 | protected ?int $activateLegal; |
||
| 353 | |||
| 354 | #[ORM\Column(name: 'add_teachers_to_sessions_courses', type: 'boolean', nullable: true)] |
||
| 355 | protected ?bool $addTeachersToSessionsCourses; |
||
| 356 | |||
| 357 | #[ORM\Column(name: 'course_type_id', type: 'integer', unique: false, nullable: true)] |
||
| 358 | protected ?int $courseTypeId; |
||
| 359 | |||
| 360 | /** |
||
| 361 | * ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course"). |
||
| 362 | */ |
||
| 363 | // protected $curriculumCategories; |
||
| 364 | |||
| 365 | #[ORM\ManyToOne(targetEntity: Room::class)] |
||
| 366 | #[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')] |
||
| 367 | protected ?Room $room; |
||
| 368 | |||
| 369 | #[Groups(['course:read', 'course_rel_user:read', 'course:write'])] |
||
| 370 | #[ORM\Column(type: 'integer', nullable: true)] |
||
| 371 | private ?int $duration = null; |
||
| 372 | |||
| 373 | #[Groups(['course:read', 'course:write'])] |
||
| 374 | #[ORM\Column(name: 'popularity', type: 'integer', nullable: false, options: ['default' => 0])] |
||
| 375 | protected int $popularity = 0; |
||
| 376 | |||
| 377 | #[Groups(['course:read'])] |
||
| 378 | public bool $subscribed = false; |
||
| 379 | |||
| 380 | #[SerializedName('allowSelfSignup')] |
||
| 381 | #[Groups(['course:read','session:read'])] |
||
| 382 | public function getAllowSelfSignup(): bool |
||
| 383 | { |
||
| 384 | return $this->visibility !== self::REGISTERED; |
||
| 385 | } |
||
| 386 | |||
| 387 | public function __construct() |
||
| 388 | { |
||
| 389 | $this->visibility = self::OPEN_PLATFORM; |
||
| 390 | $this->sessions = new ArrayCollection(); |
||
| 391 | $this->sessionRelCourseRelUsers = new ArrayCollection(); |
||
| 392 | $this->skills = new ArrayCollection(); |
||
| 393 | $this->issuedSkills = new ArrayCollection(); |
||
| 394 | $this->creationDate = new DateTime(); |
||
| 395 | $this->lastVisit = new DateTime(); |
||
| 396 | $this->lastEdit = new DateTime(); |
||
| 397 | $this->description = ''; |
||
| 398 | $this->introduction = ''; |
||
| 399 | $this->tutorName = ''; |
||
| 400 | $this->legal = ''; |
||
| 401 | $this->videoUrl = ''; |
||
| 402 | $this->registrationCode = null; |
||
| 403 | $this->users = new ArrayCollection(); |
||
| 404 | $this->urls = new ArrayCollection(); |
||
| 405 | $this->tools = new ArrayCollection(); |
||
| 406 | $this->categories = new ArrayCollection(); |
||
| 407 | $this->gradebookCategories = new ArrayCollection(); |
||
| 408 | $this->gradebookEvaluations = new ArrayCollection(); |
||
| 409 | $this->gradebookLinks = new ArrayCollection(); |
||
| 410 | $this->trackEHotspots = new ArrayCollection(); |
||
| 411 | $this->searchEngineRefs = new ArrayCollection(); |
||
| 412 | $this->templates = new ArrayCollection(); |
||
| 413 | $this->activateLegal = 0; |
||
| 414 | $this->addTeachersToSessionsCourses = false; |
||
| 415 | $this->courseTypeId = null; |
||
| 416 | $this->room = null; |
||
| 417 | $this->courseLanguage = 'en'; |
||
| 418 | $this->subscribe = true; |
||
| 419 | $this->unsubscribe = false; |
||
| 420 | $this->sticky = false; |
||
| 421 | // $this->specificFieldValues = new ArrayCollection(); |
||
| 422 | // $this->sharedSurveys = new ArrayCollection(); |
||
| 423 | } |
||
| 424 | |||
| 425 | public function __toString(): string |
||
| 426 | { |
||
| 427 | return $this->getTitle(); |
||
| 428 | } |
||
| 429 | |||
| 430 | public static function getStatusList(): array |
||
| 431 | { |
||
| 432 | return [ |
||
| 433 | self::CLOSED => 'Closed', |
||
| 434 | self::REGISTERED => 'Registered', |
||
| 435 | self::OPEN_PLATFORM => 'Open platform', |
||
| 436 | self::OPEN_WORLD => 'Open world', |
||
| 437 | self::HIDDEN => 'Hidden', |
||
| 438 | ]; |
||
| 439 | } |
||
| 440 | |||
| 441 | public function getTitle(): string |
||
| 442 | { |
||
| 443 | return $this->title; |
||
|
|
|||
| 444 | } |
||
| 445 | |||
| 446 | public function setTitle(string $title): self |
||
| 447 | { |
||
| 448 | $this->title = $title; |
||
| 449 | // Set the code based in the title if it doesnt exists. |
||
| 450 | if (empty($this->code)) { |
||
| 451 | $this->setCode($title); |
||
| 452 | } |
||
| 453 | |||
| 454 | return $this; |
||
| 455 | } |
||
| 456 | |||
| 457 | /** |
||
| 458 | * @return Collection<int, CTool> |
||
| 459 | */ |
||
| 460 | public function getTools(): Collection |
||
| 461 | { |
||
| 462 | return $this->tools; |
||
| 463 | } |
||
| 464 | |||
| 465 | public function setTools(array $tools): self |
||
| 466 | { |
||
| 467 | foreach ($tools as $tool) { |
||
| 468 | $this->addTool($tool); |
||
| 469 | } |
||
| 470 | |||
| 471 | return $this; |
||
| 472 | } |
||
| 473 | |||
| 474 | public function addTool(CTool $tool): self |
||
| 475 | { |
||
| 476 | $tool->setCourse($this); |
||
| 477 | $this->tools->add($tool); |
||
| 478 | |||
| 479 | return $this; |
||
| 480 | } |
||
| 481 | |||
| 482 | public function hasSubscriptionByUser(User $user): bool |
||
| 483 | { |
||
| 484 | return (bool) $this->getSubscriptionByUser($user); |
||
| 485 | } |
||
| 486 | |||
| 487 | public function getSubscriptionByUser(User $user): ?CourseRelUser |
||
| 488 | { |
||
| 489 | $users = $this->getUsers(); |
||
| 490 | |||
| 491 | if (0 === $users->count()) { |
||
| 492 | return null; |
||
| 493 | } |
||
| 494 | |||
| 495 | $matching = $users->filter( |
||
| 496 | fn (CourseRelUser $subscription) => $subscription->getUser()->getId() === $user->getId() |
||
| 497 | ); |
||
| 498 | |||
| 499 | return $matching->count() > 0 ? $matching->first() : null; |
||
| 500 | } |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @return Collection<int, CourseRelUser> |
||
| 504 | */ |
||
| 505 | public function getUsers(): Collection |
||
| 506 | { |
||
| 507 | return $this->users; |
||
| 508 | } |
||
| 509 | |||
| 510 | public function addSubscription(CourseRelUser $courseRelUser): self |
||
| 511 | { |
||
| 512 | $courseRelUser->setCourse($this); |
||
| 513 | if (!$this->hasUsers($courseRelUser)) { |
||
| 514 | $this->users->add($courseRelUser); |
||
| 515 | } |
||
| 516 | |||
| 517 | return $this; |
||
| 518 | } |
||
| 519 | |||
| 520 | public function removeSubscription(CourseRelUser $user): void |
||
| 521 | { |
||
| 522 | foreach ($this->users as $key => $value) { |
||
| 523 | if ($value->getId() === $user->getId()) { |
||
| 524 | unset($this->users[$key]); |
||
| 525 | } |
||
| 526 | } |
||
| 527 | } |
||
| 528 | |||
| 529 | public function hasUsers(CourseRelUser $subscription): bool |
||
| 530 | { |
||
| 531 | if (0 !== $this->users->count()) { |
||
| 532 | $criteria = Criteria::create() |
||
| 533 | ->where( |
||
| 534 | Criteria::expr()->eq('user', $subscription->getUser()) |
||
| 535 | ) |
||
| 536 | ->andWhere( |
||
| 537 | Criteria::expr()->eq('status', $subscription->getStatus()) |
||
| 538 | ) |
||
| 539 | ->andWhere( |
||
| 540 | Criteria::expr()->eq('relationType', $subscription->getRelationType()) |
||
| 541 | ) |
||
| 542 | ; |
||
| 543 | $relation = $this->users->matching($criteria); |
||
| 544 | |||
| 545 | return $relation->count() > 0; |
||
| 546 | } |
||
| 547 | |||
| 548 | return false; |
||
| 549 | } |
||
| 550 | |||
| 551 | public function addSubscriptionForUser(User $user, int $relationType, ?string $role, int $status): self |
||
| 552 | { |
||
| 553 | $courseRelUser = (new CourseRelUser()) |
||
| 554 | ->setCourse($this) |
||
| 555 | ->setUser($user) |
||
| 556 | ->setRelationType($relationType) |
||
| 557 | ->setStatus($status) |
||
| 558 | ; |
||
| 559 | $this->addSubscription($courseRelUser); |
||
| 560 | |||
| 561 | return $this; |
||
| 562 | } |
||
| 563 | |||
| 564 | public function hasUserAsStudent(User $user): bool |
||
| 565 | { |
||
| 566 | $criteria = Criteria::create()->where(Criteria::expr()->eq('user', $user)); |
||
| 567 | |||
| 568 | return $this->getStudentSubscriptions()->matching($criteria)->count() > 0; |
||
| 569 | } |
||
| 570 | |||
| 571 | public function getStudentSubscriptions(): Collection |
||
| 572 | { |
||
| 573 | $criteria = Criteria::create(); |
||
| 574 | $criteria->where(Criteria::expr()->eq('status', CourseRelUser::STUDENT)); |
||
| 575 | |||
| 576 | return $this->users->matching($criteria); |
||
| 577 | } |
||
| 578 | |||
| 579 | public function addUserAsStudent(User $user): self |
||
| 580 | { |
||
| 581 | $this->addSubscriptionForUser($user, 0, '', CourseRelUser::STUDENT); |
||
| 582 | |||
| 583 | return $this; |
||
| 584 | } |
||
| 585 | |||
| 586 | public function hasUserAsTeacher(User $user): bool |
||
| 587 | { |
||
| 588 | $users = $this->getTeachersSubscriptions(); |
||
| 589 | |||
| 590 | if (0 === $users->count()) { |
||
| 591 | return false; |
||
| 592 | } |
||
| 593 | |||
| 594 | $matching = $users->filter( |
||
| 595 | fn (CourseRelUser $subscription) => $subscription->getUser()->getId() === $user->getId() |
||
| 596 | ); |
||
| 597 | |||
| 598 | return $matching->count() > 0; |
||
| 599 | } |
||
| 600 | |||
| 601 | /** |
||
| 602 | * @return Collection<int, CourseRelUser> |
||
| 603 | */ |
||
| 604 | #[SerializedName('teachers')] |
||
| 605 | #[Groups(['course:read'])] |
||
| 606 | public function getTeachersSubscriptions(): Collection |
||
| 607 | { |
||
| 608 | $teacherSubscriptions = new ArrayCollection(); |
||
| 609 | |||
| 610 | foreach ($this->users as $subscription) { |
||
| 611 | if (CourseRelUser::TEACHER === $subscription->getStatus()) { |
||
| 612 | $teacherSubscriptions->add($subscription); |
||
| 613 | } |
||
| 614 | } |
||
| 615 | |||
| 616 | return $teacherSubscriptions; |
||
| 617 | } |
||
| 618 | |||
| 619 | public function addUserAsTeacher(User $user): self |
||
| 620 | { |
||
| 621 | $this->addSubscriptionForUser($user, 0, 'Trainer', CourseRelUser::TEACHER); |
||
| 622 | |||
| 623 | return $this; |
||
| 624 | } |
||
| 625 | |||
| 626 | public function hasGroup(CGroup $group): void |
||
| 627 | { |
||
| 628 | /*$criteria = Criteria::create()->where( |
||
| 629 | Criteria::expr()->eq('groups', $group) |
||
| 630 | );*/ |
||
| 631 | // return $this->getGroups()->contains($group); |
||
| 632 | } |
||
| 633 | |||
| 634 | public function getId(): ?int |
||
| 635 | { |
||
| 636 | return $this->id; |
||
| 637 | } |
||
| 638 | |||
| 639 | /** |
||
| 640 | * Get directory, needed in migrations. |
||
| 641 | */ |
||
| 642 | public function getDirectory(): ?string |
||
| 643 | { |
||
| 644 | return $this->directory; |
||
| 645 | } |
||
| 646 | |||
| 647 | public function getCourseLanguage(): string |
||
| 648 | { |
||
| 649 | return $this->courseLanguage; |
||
| 650 | } |
||
| 651 | |||
| 652 | public function setCourseLanguage(string $courseLanguage): self |
||
| 653 | { |
||
| 654 | $this->courseLanguage = $courseLanguage; |
||
| 655 | |||
| 656 | return $this; |
||
| 657 | } |
||
| 658 | |||
| 659 | public function getTitleAndCode(): string |
||
| 660 | { |
||
| 661 | return $this->getTitle().' ('.$this->getCode().')'; |
||
| 662 | } |
||
| 663 | |||
| 664 | public function getCode(): string |
||
| 665 | { |
||
| 666 | return $this->code; |
||
| 667 | } |
||
| 668 | |||
| 669 | public function setCode(string $code): self |
||
| 670 | { |
||
| 671 | $this->code = $code; |
||
| 672 | $this->visualCode = $code; |
||
| 673 | |||
| 674 | return $this; |
||
| 675 | } |
||
| 676 | |||
| 677 | public function getDescription(): ?string |
||
| 678 | { |
||
| 679 | return $this->description; |
||
| 680 | } |
||
| 681 | |||
| 682 | public function setDescription(string $description): self |
||
| 683 | { |
||
| 684 | $this->description = $description; |
||
| 685 | |||
| 686 | return $this; |
||
| 687 | } |
||
| 688 | |||
| 689 | /** |
||
| 690 | * @return Collection<int, CourseCategory> |
||
| 691 | */ |
||
| 692 | public function getCategories(): Collection |
||
| 693 | { |
||
| 694 | return $this->categories; |
||
| 695 | } |
||
| 696 | |||
| 697 | public function setCategories(Collection $categories): self |
||
| 698 | { |
||
| 699 | $this->categories = $categories; |
||
| 700 | |||
| 701 | return $this; |
||
| 702 | } |
||
| 703 | |||
| 704 | public function addCategory(CourseCategory $category): self |
||
| 705 | { |
||
| 706 | $this->categories[] = $category; |
||
| 707 | |||
| 708 | return $this; |
||
| 709 | } |
||
| 710 | |||
| 711 | public function removeCategory(CourseCategory $category): void |
||
| 712 | { |
||
| 713 | $this->categories->removeElement($category); |
||
| 714 | } |
||
| 715 | |||
| 716 | public function getVisibility(): int |
||
| 717 | { |
||
| 718 | return $this->visibility; |
||
| 719 | } |
||
| 720 | |||
| 721 | public function setVisibility(int $visibility): self |
||
| 722 | { |
||
| 723 | $this->visibility = $visibility; |
||
| 724 | |||
| 725 | return $this; |
||
| 726 | } |
||
| 727 | |||
| 728 | public function getShowScore(): ?int |
||
| 731 | } |
||
| 732 | |||
| 733 | public function setShowScore(int $showScore): self |
||
| 734 | { |
||
| 735 | $this->showScore = $showScore; |
||
| 736 | |||
| 737 | return $this; |
||
| 738 | } |
||
| 739 | |||
| 740 | public function getTutorName(): ?string |
||
| 743 | } |
||
| 744 | |||
| 745 | public function setTutorName(?string $tutorName): self |
||
| 746 | { |
||
| 747 | $this->tutorName = $tutorName; |
||
| 748 | |||
| 749 | return $this; |
||
| 750 | } |
||
| 751 | |||
| 752 | public function getVisualCode(): ?string |
||
| 753 | { |
||
| 754 | return $this->visualCode; |
||
| 755 | } |
||
| 756 | |||
| 757 | public function setVisualCode(string $visualCode): self |
||
| 758 | { |
||
| 759 | $this->visualCode = $visualCode; |
||
| 760 | |||
| 761 | return $this; |
||
| 762 | } |
||
| 763 | |||
| 764 | public function getDepartmentName(): ?string |
||
| 765 | { |
||
| 766 | return $this->departmentName; |
||
| 767 | } |
||
| 768 | |||
| 769 | public function setDepartmentName(string $departmentName): self |
||
| 770 | { |
||
| 771 | $this->departmentName = $departmentName; |
||
| 772 | |||
| 773 | return $this; |
||
| 774 | } |
||
| 775 | |||
| 776 | public function getDepartmentUrl(): ?string |
||
| 777 | { |
||
| 778 | return $this->departmentUrl; |
||
| 779 | } |
||
| 780 | |||
| 781 | public function setDepartmentUrl(string $departmentUrl): self |
||
| 782 | { |
||
| 783 | $this->departmentUrl = $departmentUrl; |
||
| 784 | |||
| 785 | return $this; |
||
| 786 | } |
||
| 787 | |||
| 788 | public function getDiskQuota(): ?int |
||
| 789 | { |
||
| 790 | return $this->diskQuota; |
||
| 791 | } |
||
| 792 | |||
| 793 | public function setDiskQuota(int $diskQuota): self |
||
| 794 | { |
||
| 795 | $this->diskQuota = $diskQuota; |
||
| 796 | |||
| 797 | return $this; |
||
| 798 | } |
||
| 799 | |||
| 800 | public function getLastVisit(): ?DateTime |
||
| 801 | { |
||
| 802 | return $this->lastVisit; |
||
| 803 | } |
||
| 804 | |||
| 805 | public function setLastVisit(DateTime $lastVisit): self |
||
| 810 | } |
||
| 811 | |||
| 812 | public function getLastEdit(): ?DateTime |
||
| 813 | { |
||
| 814 | return $this->lastEdit; |
||
| 815 | } |
||
| 816 | |||
| 817 | public function setLastEdit(DateTime $lastEdit): self |
||
| 818 | { |
||
| 819 | $this->lastEdit = $lastEdit; |
||
| 820 | |||
| 821 | return $this; |
||
| 822 | } |
||
| 823 | |||
| 824 | public function getCreationDate(): DateTime |
||
| 825 | { |
||
| 826 | return $this->creationDate; |
||
| 827 | } |
||
| 828 | |||
| 829 | public function setCreationDate(DateTime $creationDate): self |
||
| 830 | { |
||
| 831 | $this->creationDate = $creationDate; |
||
| 832 | |||
| 833 | return $this; |
||
| 834 | } |
||
| 835 | |||
| 836 | public function getExpirationDate(): ?DateTime |
||
| 837 | { |
||
| 838 | return $this->expirationDate; |
||
| 839 | } |
||
| 840 | |||
| 841 | public function setExpirationDate(DateTime $expirationDate): self |
||
| 842 | { |
||
| 843 | $this->expirationDate = $expirationDate; |
||
| 844 | |||
| 845 | return $this; |
||
| 846 | } |
||
| 847 | |||
| 848 | public function getSubscribe(): bool |
||
| 849 | { |
||
| 850 | return $this->subscribe; |
||
| 851 | } |
||
| 852 | |||
| 853 | public function setSubscribe(bool $subscribe): self |
||
| 854 | { |
||
| 855 | $this->subscribe = $subscribe; |
||
| 856 | |||
| 857 | return $this; |
||
| 858 | } |
||
| 859 | |||
| 860 | public function getUnsubscribe(): bool |
||
| 861 | { |
||
| 862 | return $this->unsubscribe; |
||
| 863 | } |
||
| 864 | |||
| 865 | public function setUnsubscribe(bool $unsubscribe): self |
||
| 866 | { |
||
| 867 | $this->unsubscribe = $unsubscribe; |
||
| 868 | |||
| 869 | return $this; |
||
| 870 | } |
||
| 871 | |||
| 872 | public function getRegistrationCode(): ?string |
||
| 873 | { |
||
| 874 | return $this->registrationCode; |
||
| 875 | } |
||
| 876 | |||
| 877 | public function setRegistrationCode(string $registrationCode): self |
||
| 878 | { |
||
| 879 | $this->registrationCode = $registrationCode; |
||
| 880 | |||
| 881 | return $this; |
||
| 882 | } |
||
| 883 | |||
| 884 | public function getLegal(): ?string |
||
| 885 | { |
||
| 886 | return $this->legal; |
||
| 887 | } |
||
| 888 | |||
| 889 | public function setLegal(string $legal): self |
||
| 890 | { |
||
| 891 | $this->legal = $legal; |
||
| 892 | |||
| 893 | return $this; |
||
| 894 | } |
||
| 895 | |||
| 896 | public function getActivateLegal(): ?int |
||
| 897 | { |
||
| 898 | return $this->activateLegal; |
||
| 899 | } |
||
| 900 | |||
| 901 | public function setActivateLegal(int $activateLegal): self |
||
| 902 | { |
||
| 903 | $this->activateLegal = $activateLegal; |
||
| 904 | |||
| 905 | return $this; |
||
| 906 | } |
||
| 907 | |||
| 908 | public function isAddTeachersToSessionsCourses(): ?bool |
||
| 909 | { |
||
| 910 | return $this->addTeachersToSessionsCourses; |
||
| 911 | } |
||
| 912 | |||
| 913 | public function setAddTeachersToSessionsCourses(bool $addTeachersToSessionsCourses): self |
||
| 914 | { |
||
| 915 | $this->addTeachersToSessionsCourses = $addTeachersToSessionsCourses; |
||
| 916 | |||
| 917 | return $this; |
||
| 918 | } |
||
| 919 | |||
| 920 | public function getCourseTypeId(): ?int |
||
| 921 | { |
||
| 922 | return $this->courseTypeId; |
||
| 923 | } |
||
| 924 | |||
| 925 | public function setCourseTypeId(int $courseTypeId): self |
||
| 926 | { |
||
| 927 | $this->courseTypeId = $courseTypeId; |
||
| 928 | |||
| 929 | return $this; |
||
| 930 | } |
||
| 931 | |||
| 932 | public function getRoom(): ?Room |
||
| 933 | { |
||
| 934 | return $this->room; |
||
| 935 | } |
||
| 936 | |||
| 937 | public function setRoom(Room $room): self |
||
| 938 | { |
||
| 939 | $this->room = $room; |
||
| 940 | |||
| 941 | return $this; |
||
| 942 | } |
||
| 943 | |||
| 944 | public function isActive(): bool |
||
| 945 | { |
||
| 946 | $activeVisibilityList = [self::REGISTERED, self::OPEN_PLATFORM, self::OPEN_WORLD]; |
||
| 947 | |||
| 948 | return \in_array($this->visibility, $activeVisibilityList, true); |
||
| 949 | } |
||
| 950 | |||
| 951 | /** |
||
| 952 | * Anybody can see this course. |
||
| 953 | */ |
||
| 954 | public function isPublic(): bool |
||
| 955 | { |
||
| 956 | return self::OPEN_WORLD === $this->visibility; |
||
| 957 | } |
||
| 958 | |||
| 959 | public function isHidden(): bool |
||
| 960 | { |
||
| 961 | return self::HIDDEN === $this->visibility; |
||
| 962 | } |
||
| 963 | |||
| 964 | public function getCurrentSession(): Session |
||
| 965 | { |
||
| 966 | return $this->currentSession; |
||
| 967 | } |
||
| 968 | |||
| 969 | public function setCurrentSession(Session $session): self |
||
| 970 | { |
||
| 971 | // If the session is registered in the course session list. |
||
| 972 | /*if ($this->getSessions()->contains($session->getId())) { |
||
| 973 | $this->currentSession = $session; |
||
| 974 | }*/ |
||
| 975 | $list = $this->getSessions(); |
||
| 976 | |||
| 977 | /** @var SessionRelCourse $item */ |
||
| 978 | foreach ($list as $item) { |
||
| 979 | if ($item->getSession()->getId() === $session->getId()) { |
||
| 980 | $this->currentSession = $session; |
||
| 981 | |||
| 982 | break; |
||
| 983 | } |
||
| 984 | } |
||
| 985 | |||
| 986 | return $this; |
||
| 987 | } |
||
| 988 | |||
| 989 | /** |
||
| 990 | * @return Collection<int, SessionRelCourse> |
||
| 991 | */ |
||
| 992 | public function getSessions(): Collection |
||
| 993 | { |
||
| 994 | return $this->sessions; |
||
| 995 | } |
||
| 996 | |||
| 997 | public function getCurrentUrl(): AccessUrl |
||
| 998 | { |
||
| 999 | return $this->currentUrl; |
||
| 1000 | } |
||
| 1001 | |||
| 1002 | public function setCurrentUrl(AccessUrl $url): self |
||
| 1003 | { |
||
| 1004 | $urlList = $this->getUrls(); |
||
| 1005 | |||
| 1006 | /** @var AccessUrlRelCourse $item */ |
||
| 1007 | foreach ($urlList as $item) { |
||
| 1008 | if ($item->getUrl()->getId() === $url->getId()) { |
||
| 1009 | $this->currentUrl = $url; |
||
| 1010 | |||
| 1011 | break; |
||
| 1012 | } |
||
| 1013 | } |
||
| 1014 | |||
| 1015 | return $this; |
||
| 1016 | } |
||
| 1017 | |||
| 1018 | public function getUrls(): Collection |
||
| 1021 | } |
||
| 1022 | |||
| 1023 | public function addUrls(AccessUrlRelCourse $urlRelCourse): static |
||
| 1024 | { |
||
| 1025 | if (!$this->urls->contains($urlRelCourse)) { |
||
| 1026 | $this->urls->add($urlRelCourse); |
||
| 1027 | $urlRelCourse->setCourse($this); |
||
| 1028 | } |
||
| 1029 | |||
| 1030 | return $this; |
||
| 1031 | } |
||
| 1032 | |||
| 1033 | public function addAccessUrl(?AccessUrl $url): self |
||
| 1034 | { |
||
| 1035 | $urlRelCourse = (new AccessUrlRelCourse())->setUrl($url); |
||
| 1036 | $this->addUrls($urlRelCourse); |
||
| 1037 | |||
| 1038 | return $this; |
||
| 1039 | } |
||
| 1040 | |||
| 1041 | /** |
||
| 1042 | * @return Collection<int, SkillRelUser> |
||
| 1043 | */ |
||
| 1044 | public function getIssuedSkills(): Collection |
||
| 1045 | { |
||
| 1046 | return $this->issuedSkills; |
||
| 1047 | } |
||
| 1048 | |||
| 1049 | /** |
||
| 1050 | * @return Collection<int, SessionRelCourseRelUser> |
||
| 1051 | */ |
||
| 1052 | public function getSessionRelCourseRelUsers(): Collection |
||
| 1053 | { |
||
| 1054 | return $this->sessionRelCourseRelUsers; |
||
| 1055 | } |
||
| 1056 | |||
| 1057 | public function setSessionRelCourseRelUsers(Collection $sessionUserSubscriptions): self |
||
| 1058 | { |
||
| 1059 | $this->sessionRelCourseRelUsers = $sessionUserSubscriptions; |
||
| 1060 | |||
| 1061 | return $this; |
||
| 1062 | } |
||
| 1063 | |||
| 1064 | /** |
||
| 1065 | * @return Collection<int, SkillRelCourse> |
||
| 1066 | */ |
||
| 1067 | public function getSkills(): Collection |
||
| 1068 | { |
||
| 1069 | return $this->skills; |
||
| 1070 | } |
||
| 1071 | |||
| 1072 | public function setSkills(Collection $skills): self |
||
| 1073 | { |
||
| 1074 | $this->skills = $skills; |
||
| 1075 | |||
| 1076 | return $this; |
||
| 1077 | } |
||
| 1078 | |||
| 1079 | /** |
||
| 1080 | * @return Collection<int, GradebookCategory> |
||
| 1081 | */ |
||
| 1082 | public function getGradebookCategories(): Collection |
||
| 1083 | { |
||
| 1084 | return $this->gradebookCategories; |
||
| 1085 | } |
||
| 1086 | |||
| 1087 | public function setGradebookCategories(Collection $gradebookCategories): self |
||
| 1088 | { |
||
| 1089 | $this->gradebookCategories = $gradebookCategories; |
||
| 1090 | |||
| 1091 | return $this; |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | /** |
||
| 1095 | * @return Collection<int, GradebookEvaluation> |
||
| 1096 | */ |
||
| 1097 | public function getGradebookEvaluations(): Collection |
||
| 1098 | { |
||
| 1099 | return $this->gradebookEvaluations; |
||
| 1100 | } |
||
| 1101 | |||
| 1102 | public function setGradebookEvaluations(Collection $gradebookEvaluations): self |
||
| 1103 | { |
||
| 1104 | $this->gradebookEvaluations = $gradebookEvaluations; |
||
| 1105 | |||
| 1106 | return $this; |
||
| 1107 | } |
||
| 1108 | |||
| 1109 | /** |
||
| 1110 | * @return Collection<int, GradebookLink> |
||
| 1111 | */ |
||
| 1112 | public function getGradebookLinks(): Collection |
||
| 1113 | { |
||
| 1114 | return $this->gradebookLinks; |
||
| 1115 | } |
||
| 1116 | |||
| 1117 | public function setGradebookLinks(Collection $gradebookLinks): self |
||
| 1122 | } |
||
| 1123 | |||
| 1124 | /** |
||
| 1125 | * @return Collection<int, TrackEHotspot> |
||
| 1126 | */ |
||
| 1127 | public function getTrackEHotspots(): Collection |
||
| 1128 | { |
||
| 1129 | return $this->trackEHotspots; |
||
| 1130 | } |
||
| 1131 | |||
| 1132 | public function setTrackEHotspots(Collection $trackEHotspots): self |
||
| 1133 | { |
||
| 1134 | $this->trackEHotspots = $trackEHotspots; |
||
| 1135 | |||
| 1136 | return $this; |
||
| 1137 | } |
||
| 1138 | |||
| 1139 | /** |
||
| 1140 | * @return Collection<int, SearchEngineRef> |
||
| 1141 | */ |
||
| 1142 | public function getSearchEngineRefs(): Collection |
||
| 1143 | { |
||
| 1144 | return $this->searchEngineRefs; |
||
| 1145 | } |
||
| 1146 | |||
| 1147 | public function setSearchEngineRefs(Collection $searchEngineRefs): self |
||
| 1148 | { |
||
| 1149 | $this->searchEngineRefs = $searchEngineRefs; |
||
| 1150 | |||
| 1151 | return $this; |
||
| 1152 | } |
||
| 1153 | |||
| 1154 | public function getIntroduction(): ?string |
||
| 1155 | { |
||
| 1156 | return $this->introduction; |
||
| 1157 | } |
||
| 1158 | |||
| 1159 | public function setIntroduction(?string $introduction): self |
||
| 1160 | { |
||
| 1161 | $this->introduction = $introduction; |
||
| 1162 | |||
| 1163 | return $this; |
||
| 1164 | } |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * @return Collection<int, Templates> |
||
| 1168 | */ |
||
| 1169 | public function getTemplates(): Collection |
||
| 1170 | { |
||
| 1171 | return $this->templates; |
||
| 1172 | } |
||
| 1173 | |||
| 1174 | public function setTemplates(Collection $templates): self |
||
| 1175 | { |
||
| 1176 | $this->templates = $templates; |
||
| 1177 | |||
| 1178 | return $this; |
||
| 1179 | } |
||
| 1180 | |||
| 1181 | public function getVideoUrl(): string |
||
| 1182 | { |
||
| 1183 | return $this->videoUrl; |
||
| 1184 | } |
||
| 1185 | |||
| 1186 | public function setVideoUrl(string $videoUrl): self |
||
| 1191 | } |
||
| 1192 | |||
| 1193 | public function isSticky(): bool |
||
| 1194 | { |
||
| 1195 | return $this->sticky; |
||
| 1196 | } |
||
| 1197 | |||
| 1198 | public function setSticky(bool $sticky): self |
||
| 1199 | { |
||
| 1200 | $this->sticky = $sticky; |
||
| 1201 | |||
| 1202 | return $this; |
||
| 1203 | } |
||
| 1204 | |||
| 1205 | public function getDefaultIllustration(int $size): string |
||
| 1208 | } |
||
| 1209 | |||
| 1210 | public function getDuration(): ?int |
||
| 1211 | { |
||
| 1212 | return $this->duration; |
||
| 1213 | } |
||
| 1214 | |||
| 1215 | public function setDuration(?int $duration): self |
||
| 1216 | { |
||
| 1217 | $this->duration = $duration; |
||
| 1218 | |||
| 1219 | return $this; |
||
| 1220 | } |
||
| 1221 | |||
| 1222 | public function getPopularity(): int |
||
| 1223 | { |
||
| 1224 | return $this->popularity; |
||
| 1225 | } |
||
| 1226 | |||
| 1227 | public function setPopularity(int $popularity): self |
||
| 1228 | { |
||
| 1229 | $this->popularity = $popularity; |
||
| 1230 | |||
| 1231 | return $this; |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | public function getResourceIdentifier(): int |
||
| 1235 | { |
||
| 1236 | return $this->getId(); |
||
| 1237 | } |
||
| 1238 | |||
| 1239 | public function getResourceName(): string |
||
| 1242 | } |
||
| 1243 | |||
| 1244 | public function setResourceName(string $name): self |
||
| 1245 | { |
||
| 1246 | return $this->setCode($name); |
||
| 1247 | } |
||
| 1248 | } |
||
| 1249 |