chamilo /
chamilo-lms
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /* For licensing terms, see /license.txt */ |
||||||
| 4 | |||||||
| 5 | declare(strict_types=1); |
||||||
| 6 | |||||||
| 7 | namespace Chamilo\CourseBundle\Entity; |
||||||
| 8 | |||||||
| 9 | use ApiPlatform\Doctrine\Orm\Filter\DateFilter; |
||||||
| 10 | use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
||||||
| 11 | use ApiPlatform\Metadata\ApiFilter; |
||||||
| 12 | use ApiPlatform\Metadata\ApiResource; |
||||||
| 13 | use ApiPlatform\Metadata\Delete; |
||||||
| 14 | use ApiPlatform\Metadata\Get; |
||||||
| 15 | use ApiPlatform\Metadata\GetCollection; |
||||||
| 16 | use ApiPlatform\Metadata\Post; |
||||||
| 17 | use ApiPlatform\Metadata\Put; |
||||||
| 18 | use Chamilo\CoreBundle\ApiResource\CalendarEvent; |
||||||
| 19 | use Chamilo\CoreBundle\Controller\Api\UpdateCCalendarEventAction; |
||||||
| 20 | use Chamilo\CoreBundle\Entity\AbstractResource; |
||||||
| 21 | use Chamilo\CoreBundle\Entity\AgendaReminder; |
||||||
| 22 | use Chamilo\CoreBundle\Entity\Career; |
||||||
| 23 | use Chamilo\CoreBundle\Entity\Promotion; |
||||||
| 24 | use Chamilo\CoreBundle\Entity\ResourceInterface; |
||||||
| 25 | use Chamilo\CoreBundle\Entity\Room; |
||||||
| 26 | use Chamilo\CoreBundle\Filter\CidFilter; |
||||||
| 27 | use Chamilo\CoreBundle\Filter\GlobalEventFilter; |
||||||
| 28 | use Chamilo\CoreBundle\Filter\SidFilter; |
||||||
| 29 | use Chamilo\CoreBundle\State\CalendarEventStateProvider; |
||||||
| 30 | use Chamilo\CoreBundle\State\CCalendarEventStateProcessor; |
||||||
| 31 | use Chamilo\CourseBundle\Repository\CCalendarEventRepository; |
||||||
| 32 | use DateTime; |
||||||
| 33 | use Doctrine\Common\Collections\ArrayCollection; |
||||||
| 34 | use Doctrine\Common\Collections\Collection; |
||||||
| 35 | use Doctrine\ORM\Mapping as ORM; |
||||||
| 36 | use Stringable; |
||||||
| 37 | use Symfony\Component\Serializer\Annotation\Groups; |
||||||
| 38 | use Symfony\Component\Uid\Uuid; |
||||||
| 39 | use Symfony\Component\Validator\Constraints as Assert; |
||||||
| 40 | |||||||
| 41 | /** |
||||||
| 42 | * Calendar events. |
||||||
| 43 | */ |
||||||
| 44 | #[ApiResource( |
||||||
| 45 | operations: [ |
||||||
| 46 | new Get(security: "is_granted('VIEW', object)"), |
||||||
| 47 | new Put( |
||||||
| 48 | controller: UpdateCCalendarEventAction::class, |
||||||
| 49 | security: "is_granted('EDIT', object)", |
||||||
| 50 | deserialize: false |
||||||
| 51 | ), |
||||||
| 52 | new Delete(security: "is_granted('DELETE', object)"), |
||||||
| 53 | new GetCollection( |
||||||
| 54 | paginationEnabled: false, |
||||||
| 55 | security: "is_granted('ROLE_USER')", |
||||||
| 56 | output: CalendarEvent::class, |
||||||
| 57 | provider: CalendarEventStateProvider::class, |
||||||
| 58 | ), |
||||||
| 59 | new Post( |
||||||
| 60 | securityPostDenormalize: "is_granted('CREATE', object)", |
||||||
| 61 | processor: CCalendarEventStateProcessor::class |
||||||
| 62 | ), |
||||||
| 63 | ], |
||||||
| 64 | normalizationContext: [ |
||||||
| 65 | 'groups' => ['calendar_event:read', 'resource_node:read'], |
||||||
| 66 | 'enable_max_depth' => true, |
||||||
| 67 | ], |
||||||
| 68 | denormalizationContext: ['groups' => ['calendar_event:write']], |
||||||
| 69 | security: "is_granted('ROLE_USER')" |
||||||
| 70 | )] |
||||||
| 71 | #[ORM\Table(name: 'c_calendar_event')] |
||||||
| 72 | #[ORM\Entity(repositoryClass: CCalendarEventRepository::class)] |
||||||
| 73 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['allDay' => 'boolean'])] |
||||||
| 74 | #[ApiFilter(filterClass: DateFilter::class, strategy: 'exclude_null')] |
||||||
| 75 | #[ApiFilter(filterClass: CidFilter::class)] |
||||||
| 76 | #[ApiFilter(filterClass: SidFilter::class)] |
||||||
| 77 | #[ApiFilter(GlobalEventFilter::class, properties: ['type'])] |
||||||
| 78 | class CCalendarEvent extends AbstractResource implements ResourceInterface, Stringable |
||||||
| 79 | { |
||||||
| 80 | public const COLOR_STUDENT_PUBLICATION = '#FF8C00'; |
||||||
| 81 | |||||||
| 82 | public const TYPE_INVITATION = 'invitation'; |
||||||
| 83 | public const TYPE_SUBSCRIPTION = 'subscription'; |
||||||
| 84 | |||||||
| 85 | public const SUBSCRIPTION_VISIBILITY_NO = 0; |
||||||
| 86 | public const SUBSCRIPTION_VISIBILITY_ALL = 1; |
||||||
| 87 | public const SUBSCRIPTION_VISIBILITY_CLASS = 2; |
||||||
| 88 | |||||||
| 89 | #[Groups(['calendar_event:read'])] |
||||||
| 90 | #[ORM\Column(name: 'iid', type: 'integer')] |
||||||
| 91 | #[ORM\Id] |
||||||
| 92 | #[ORM\GeneratedValue] |
||||||
| 93 | protected ?int $iid = null; |
||||||
| 94 | |||||||
| 95 | #[Groups(['calendar_event:write', 'calendar_event:read'])] |
||||||
| 96 | #[Assert\NotBlank] |
||||||
| 97 | #[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)] |
||||||
| 98 | protected string $title; |
||||||
| 99 | |||||||
| 100 | #[Groups(['calendar_event:write', 'calendar_event:read'])] |
||||||
| 101 | #[ORM\Column(name: 'content', type: 'text', nullable: true)] |
||||||
| 102 | protected ?string $content = null; |
||||||
| 103 | |||||||
| 104 | #[Groups(['calendar_event:write', 'calendar_event:read'])] |
||||||
| 105 | #[ORM\Column(name: 'start_date', type: 'datetime', nullable: true)] |
||||||
| 106 | protected ?DateTime $startDate = null; |
||||||
| 107 | |||||||
| 108 | #[Groups(['calendar_event:write', 'calendar_event:read'])] |
||||||
| 109 | #[ORM\Column(name: 'end_date', type: 'datetime', nullable: true)] |
||||||
| 110 | protected ?DateTime $endDate = null; |
||||||
| 111 | |||||||
| 112 | #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] |
||||||
| 113 | #[ORM\JoinColumn(name: 'parent_event_id', referencedColumnName: 'iid')] |
||||||
| 114 | protected ?CCalendarEvent $parentEvent = null; |
||||||
| 115 | |||||||
| 116 | /** |
||||||
| 117 | * @var Collection<int, CCalendarEvent> |
||||||
| 118 | */ |
||||||
| 119 | #[ORM\OneToMany(mappedBy: 'parentEvent', targetEntity: self::class)] |
||||||
| 120 | protected Collection $children; |
||||||
| 121 | |||||||
| 122 | /** |
||||||
| 123 | * @var Collection<int, CCalendarEventRepeat> |
||||||
| 124 | */ |
||||||
| 125 | #[ORM\OneToMany( |
||||||
| 126 | mappedBy: 'event', |
||||||
| 127 | targetEntity: CCalendarEventRepeat::class, |
||||||
| 128 | cascade: ['persist'], |
||||||
| 129 | orphanRemoval: true |
||||||
| 130 | )] |
||||||
| 131 | protected Collection $repeatEvents; |
||||||
| 132 | |||||||
| 133 | #[Assert\NotNull] |
||||||
| 134 | #[ORM\Column(name: 'all_day', type: 'boolean', nullable: false)] |
||||||
| 135 | protected bool $allDay; |
||||||
| 136 | |||||||
| 137 | #[ORM\Column(name: 'comment', type: 'text', nullable: true)] |
||||||
| 138 | protected ?string $comment = null; |
||||||
| 139 | |||||||
| 140 | #[Groups(['calendar_event:write', 'calendar_event:read'])] |
||||||
| 141 | #[ORM\Column(name: 'color', type: 'string', length: 20, nullable: true)] |
||||||
| 142 | protected ?string $color = null; |
||||||
| 143 | |||||||
| 144 | #[ORM\ManyToOne(targetEntity: Room::class)] |
||||||
| 145 | #[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')] |
||||||
| 146 | protected ?Room $room = null; |
||||||
| 147 | |||||||
| 148 | /** |
||||||
| 149 | * @var Collection<int, CCalendarEventAttachment> |
||||||
| 150 | */ |
||||||
| 151 | #[ORM\OneToMany(mappedBy: 'event', targetEntity: CCalendarEventAttachment::class, cascade: ['persist', 'remove'])] |
||||||
| 152 | protected Collection $attachments; |
||||||
| 153 | |||||||
| 154 | #[Groups(['calendar_event:write'])] |
||||||
| 155 | #[ORM\Column(name: 'invitation_type', type: 'string', nullable: true)] |
||||||
| 156 | protected ?string $invitationType = null; |
||||||
| 157 | |||||||
| 158 | #[Groups(['calendar_event:write'])] |
||||||
| 159 | #[Assert\NotNull] |
||||||
| 160 | #[ORM\Column(name: 'collective', type: 'boolean')] |
||||||
| 161 | protected bool $collective = false; |
||||||
| 162 | |||||||
| 163 | #[Groups(['calendar_event:write'])] |
||||||
| 164 | #[ORM\Column(name: 'subscription_visibility', type: 'integer')] |
||||||
| 165 | protected int $subscriptionVisibility = self::SUBSCRIPTION_VISIBILITY_NO; |
||||||
| 166 | |||||||
| 167 | #[Groups(['calendar_event:write'])] |
||||||
| 168 | #[ORM\Column(name: 'subscription_item_id', type: 'integer', nullable: true)] |
||||||
| 169 | protected ?int $subscriptionItemId = null; |
||||||
| 170 | |||||||
| 171 | #[Groups(['calendar_event:write'])] |
||||||
| 172 | #[ORM\Column(name: 'max_attendees', type: 'integer')] |
||||||
| 173 | protected int $maxAttendees = 0; |
||||||
| 174 | |||||||
| 175 | /** |
||||||
| 176 | * @var Collection<int, AgendaReminder> |
||||||
| 177 | */ |
||||||
| 178 | #[Groups(['calendar_event:write'])] |
||||||
| 179 | #[ORM\OneToMany(mappedBy: 'event', targetEntity: AgendaReminder::class, cascade: ['persist'], orphanRemoval: true)] |
||||||
| 180 | private Collection $reminders; |
||||||
| 181 | |||||||
| 182 | #[ORM\ManyToOne(targetEntity: Career::class)] |
||||||
| 183 | #[ORM\JoinColumn(name: 'career_id', referencedColumnName: 'id', nullable: true)] |
||||||
| 184 | protected ?Career $career = null; |
||||||
| 185 | |||||||
| 186 | #[ORM\ManyToOne(targetEntity: Promotion::class)] |
||||||
| 187 | #[ORM\JoinColumn(name: 'promotion_id', referencedColumnName: 'id', nullable: true)] |
||||||
| 188 | protected ?Promotion $promotion = null; |
||||||
| 189 | |||||||
| 190 | public function __construct() |
||||||
| 191 | { |
||||||
| 192 | $this->children = new ArrayCollection(); |
||||||
| 193 | $this->attachments = new ArrayCollection(); |
||||||
| 194 | $this->repeatEvents = new ArrayCollection(); |
||||||
| 195 | $this->allDay = false; |
||||||
| 196 | $this->collective = false; |
||||||
| 197 | $this->reminders = new ArrayCollection(); |
||||||
| 198 | } |
||||||
| 199 | |||||||
| 200 | public function __toString(): string |
||||||
| 201 | { |
||||||
| 202 | return $this->getTitle(); |
||||||
| 203 | } |
||||||
| 204 | |||||||
| 205 | public function getTitle(): string |
||||||
| 206 | { |
||||||
| 207 | return $this->title; |
||||||
| 208 | } |
||||||
| 209 | |||||||
| 210 | public function setTitle(string $title): self |
||||||
| 211 | { |
||||||
| 212 | $this->title = $title; |
||||||
| 213 | |||||||
| 214 | return $this; |
||||||
| 215 | } |
||||||
| 216 | |||||||
| 217 | public function getContent(): ?string |
||||||
| 218 | { |
||||||
| 219 | return $this->content; |
||||||
| 220 | } |
||||||
| 221 | |||||||
| 222 | public function setContent(string $content): self |
||||||
| 223 | { |
||||||
| 224 | $this->content = $content; |
||||||
| 225 | |||||||
| 226 | return $this; |
||||||
| 227 | } |
||||||
| 228 | |||||||
| 229 | public function getStartDate(): ?DateTime |
||||||
| 230 | { |
||||||
| 231 | return $this->startDate; |
||||||
| 232 | } |
||||||
| 233 | |||||||
| 234 | public function setStartDate(?DateTime $startDate): self |
||||||
| 235 | { |
||||||
| 236 | $this->startDate = $startDate; |
||||||
| 237 | |||||||
| 238 | return $this; |
||||||
| 239 | } |
||||||
| 240 | |||||||
| 241 | public function getEndDate(): ?DateTime |
||||||
| 242 | { |
||||||
| 243 | return $this->endDate; |
||||||
| 244 | } |
||||||
| 245 | |||||||
| 246 | public function setEndDate(?DateTime $endDate): self |
||||||
| 247 | { |
||||||
| 248 | $this->endDate = $endDate; |
||||||
| 249 | |||||||
| 250 | return $this; |
||||||
| 251 | } |
||||||
| 252 | |||||||
| 253 | public function getParentEvent(): ?self |
||||||
| 254 | { |
||||||
| 255 | return $this->parentEvent; |
||||||
| 256 | } |
||||||
| 257 | |||||||
| 258 | public function setParentEvent(self $parent): self |
||||||
| 259 | { |
||||||
| 260 | $this->parentEvent = $parent; |
||||||
| 261 | |||||||
| 262 | return $this; |
||||||
| 263 | } |
||||||
| 264 | |||||||
| 265 | public function addChild(self $event): self |
||||||
| 266 | { |
||||||
| 267 | if (!$this->getChildren()->contains($event)) { |
||||||
| 268 | $this->getChildren()->add($event); |
||||||
| 269 | } |
||||||
| 270 | |||||||
| 271 | return $this; |
||||||
| 272 | } |
||||||
| 273 | |||||||
| 274 | /** |
||||||
| 275 | * @return Collection<int, CCalendarEvent> |
||||||
| 276 | */ |
||||||
| 277 | public function getChildren(): Collection |
||||||
| 278 | { |
||||||
| 279 | return $this->children; |
||||||
| 280 | } |
||||||
| 281 | |||||||
| 282 | /** |
||||||
| 283 | * @param Collection<int, CCalendarEvent> $children |
||||||
| 284 | */ |
||||||
| 285 | public function setChildren(Collection $children): self |
||||||
| 286 | { |
||||||
| 287 | $this->children = $children; |
||||||
| 288 | |||||||
| 289 | return $this; |
||||||
| 290 | } |
||||||
| 291 | |||||||
| 292 | public function isAllDay(): bool |
||||||
| 293 | { |
||||||
| 294 | return $this->allDay; |
||||||
| 295 | } |
||||||
| 296 | |||||||
| 297 | public function setAllDay(bool $allDay): self |
||||||
| 298 | { |
||||||
| 299 | $this->allDay = $allDay; |
||||||
| 300 | |||||||
| 301 | return $this; |
||||||
| 302 | } |
||||||
| 303 | |||||||
| 304 | public function getComment(): ?string |
||||||
| 305 | { |
||||||
| 306 | return $this->comment; |
||||||
| 307 | } |
||||||
| 308 | |||||||
| 309 | public function setComment(string $comment): self |
||||||
| 310 | { |
||||||
| 311 | $this->comment = $comment; |
||||||
| 312 | |||||||
| 313 | return $this; |
||||||
| 314 | } |
||||||
| 315 | |||||||
| 316 | public function getRoom(): ?Room |
||||||
| 317 | { |
||||||
| 318 | return $this->room; |
||||||
| 319 | } |
||||||
| 320 | |||||||
| 321 | public function setRoom(Room $room): self |
||||||
| 322 | { |
||||||
| 323 | $this->room = $room; |
||||||
| 324 | |||||||
| 325 | return $this; |
||||||
| 326 | } |
||||||
| 327 | |||||||
| 328 | public function getColor(): ?string |
||||||
| 329 | { |
||||||
| 330 | return $this->color; |
||||||
| 331 | } |
||||||
| 332 | |||||||
| 333 | public function setColor(string $color): self |
||||||
| 334 | { |
||||||
| 335 | $this->color = $color; |
||||||
| 336 | |||||||
| 337 | return $this; |
||||||
| 338 | } |
||||||
| 339 | |||||||
| 340 | /** |
||||||
| 341 | * @return Collection<int, CCalendarEventAttachment> |
||||||
| 342 | */ |
||||||
| 343 | public function getAttachments(): Collection |
||||||
| 344 | { |
||||||
| 345 | return $this->attachments; |
||||||
| 346 | } |
||||||
| 347 | |||||||
| 348 | public function setAttachments(Collection $attachments): self |
||||||
| 349 | { |
||||||
| 350 | $this->attachments = $attachments; |
||||||
| 351 | |||||||
| 352 | return $this; |
||||||
| 353 | } |
||||||
| 354 | |||||||
| 355 | public function addAttachment(CCalendarEventAttachment $attachment): self |
||||||
| 356 | { |
||||||
| 357 | $this->attachments->add($attachment); |
||||||
| 358 | |||||||
| 359 | return $this; |
||||||
| 360 | } |
||||||
| 361 | |||||||
| 362 | /** |
||||||
| 363 | * @return Collection<int, CCalendarEventRepeat> |
||||||
| 364 | */ |
||||||
| 365 | public function getRepeatEvents(): Collection |
||||||
| 366 | { |
||||||
| 367 | return $this->repeatEvents; |
||||||
| 368 | } |
||||||
| 369 | |||||||
| 370 | /** |
||||||
| 371 | * @param Collection<int, CCalendarEventRepeat> $repeatEvents |
||||||
| 372 | */ |
||||||
| 373 | public function setRepeatEvents(Collection $repeatEvents): self |
||||||
| 374 | { |
||||||
| 375 | $this->repeatEvents = $repeatEvents; |
||||||
| 376 | |||||||
| 377 | return $this; |
||||||
| 378 | } |
||||||
| 379 | |||||||
| 380 | public function getResourceIdentifier(): int|Uuid |
||||||
| 381 | { |
||||||
| 382 | return $this->getIid(); |
||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||||
| 383 | } |
||||||
| 384 | |||||||
| 385 | public function getIid(): ?int |
||||||
| 386 | { |
||||||
| 387 | return $this->iid; |
||||||
| 388 | } |
||||||
| 389 | |||||||
| 390 | public function getResourceName(): string |
||||||
| 391 | { |
||||||
| 392 | return $this->getTitle(); |
||||||
| 393 | } |
||||||
| 394 | |||||||
| 395 | public function setResourceName(string $name): self |
||||||
| 396 | { |
||||||
| 397 | return $this->setTitle($name); |
||||||
| 398 | } |
||||||
| 399 | |||||||
| 400 | public function isCollective(): bool |
||||||
| 401 | { |
||||||
| 402 | return $this->collective; |
||||||
| 403 | } |
||||||
| 404 | |||||||
| 405 | public function setCollective(bool $collective): self |
||||||
| 406 | { |
||||||
| 407 | $this->collective = $collective; |
||||||
| 408 | |||||||
| 409 | return $this; |
||||||
| 410 | } |
||||||
| 411 | |||||||
| 412 | public function getInvitationType(): ?string |
||||||
| 413 | { |
||||||
| 414 | return $this->invitationType; |
||||||
| 415 | } |
||||||
| 416 | |||||||
| 417 | public function setInvitationType(string $invitationType): self |
||||||
| 418 | { |
||||||
| 419 | $this->invitationType = $invitationType; |
||||||
| 420 | |||||||
| 421 | return $this; |
||||||
| 422 | } |
||||||
| 423 | |||||||
| 424 | public function getSubscriptionVisibility(): int |
||||||
| 425 | { |
||||||
| 426 | return $this->subscriptionVisibility; |
||||||
| 427 | } |
||||||
| 428 | |||||||
| 429 | public function setSubscriptionVisibility(int $subscriptionVisibility): self |
||||||
| 430 | { |
||||||
| 431 | $this->subscriptionVisibility = $subscriptionVisibility; |
||||||
| 432 | |||||||
| 433 | return $this; |
||||||
| 434 | } |
||||||
| 435 | |||||||
| 436 | public function getSubscriptionItemId(): ?int |
||||||
| 437 | { |
||||||
| 438 | return $this->subscriptionItemId; |
||||||
| 439 | } |
||||||
| 440 | |||||||
| 441 | public function setSubscriptionItemId(?int $subscriptionItemId): self |
||||||
| 442 | { |
||||||
| 443 | $this->subscriptionItemId = $subscriptionItemId; |
||||||
| 444 | |||||||
| 445 | return $this; |
||||||
| 446 | } |
||||||
| 447 | |||||||
| 448 | public function getMaxAttendees(): int |
||||||
| 449 | { |
||||||
| 450 | return $this->maxAttendees; |
||||||
| 451 | } |
||||||
| 452 | |||||||
| 453 | public function setMaxAttendees(int $maxAttendees): self |
||||||
| 454 | { |
||||||
| 455 | $this->maxAttendees = $maxAttendees; |
||||||
| 456 | |||||||
| 457 | return $this; |
||||||
| 458 | } |
||||||
| 459 | |||||||
| 460 | /** |
||||||
| 461 | * @return Collection<int, AgendaReminder> |
||||||
| 462 | */ |
||||||
| 463 | public function getReminders(): Collection |
||||||
| 464 | { |
||||||
| 465 | return $this->reminders; |
||||||
| 466 | } |
||||||
| 467 | |||||||
| 468 | public function addReminder(AgendaReminder $reminder): static |
||||||
| 469 | { |
||||||
| 470 | if (!$this->reminders->contains($reminder)) { |
||||||
| 471 | $this->reminders->add($reminder); |
||||||
| 472 | $reminder->setEvent($this); |
||||||
| 473 | } |
||||||
| 474 | |||||||
| 475 | return $this; |
||||||
| 476 | } |
||||||
| 477 | |||||||
| 478 | public function removeReminder(AgendaReminder $reminder): static |
||||||
| 479 | { |
||||||
| 480 | if ($this->reminders->removeElement($reminder)) { |
||||||
| 481 | // set the owning side to null (unless already changed) |
||||||
| 482 | if ($reminder->getEvent() === $this) { |
||||||
| 483 | $reminder->setEvent(null); |
||||||
| 484 | } |
||||||
| 485 | } |
||||||
| 486 | |||||||
| 487 | return $this; |
||||||
| 488 | } |
||||||
| 489 | |||||||
| 490 | public function getCareer(): ?Career |
||||||
| 491 | { |
||||||
| 492 | return $this->career; |
||||||
| 493 | } |
||||||
| 494 | |||||||
| 495 | public function setCareer(?Career $career): self |
||||||
| 496 | { |
||||||
| 497 | $this->career = $career; |
||||||
| 498 | |||||||
| 499 | return $this; |
||||||
| 500 | } |
||||||
| 501 | |||||||
| 502 | public function getPromotion(): ?Promotion |
||||||
| 503 | { |
||||||
| 504 | return $this->promotion; |
||||||
| 505 | } |
||||||
| 506 | |||||||
| 507 | public function setPromotion(?Promotion $promotion): self |
||||||
| 508 | { |
||||||
| 509 | $this->promotion = $promotion; |
||||||
| 510 | |||||||
| 511 | return $this; |
||||||
| 512 | } |
||||||
| 513 | |||||||
| 514 | public function determineType(): string |
||||||
| 515 | { |
||||||
| 516 | $resourceLinks = $this->resourceNode->getResourceLinks(); |
||||||
|
0 ignored issues
–
show
The method
getResourceLinks() does not exist on null.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 517 | |||||||
| 518 | foreach ($resourceLinks as $link) { |
||||||
| 519 | if (null !== $link->getCourse() && null === $link->getSession()) { |
||||||
| 520 | return 'course'; |
||||||
| 521 | } |
||||||
| 522 | |||||||
| 523 | if (null !== $link->getSession()) { |
||||||
| 524 | return 'session'; |
||||||
| 525 | } |
||||||
| 526 | |||||||
| 527 | if (null === $link->getCourse() |
||||||
| 528 | && null === $link->getSession() |
||||||
| 529 | && null === $link->getGroup() |
||||||
| 530 | && null === $link->getUser() |
||||||
| 531 | ) { |
||||||
| 532 | return 'global'; |
||||||
| 533 | } |
||||||
| 534 | } |
||||||
| 535 | |||||||
| 536 | return 'personal'; |
||||||
| 537 | } |
||||||
| 538 | } |
||||||
| 539 |