src/Entity/ChannelUserData/Cursus/SessionCursus.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ChannelUserData\Cursus;
  3. use App\Entity\Channel\Session;
  4. use App\Repository\ChannelUserData\Cursus\SessionCursusRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[
  9. ORM\Entity(repositoryClass: SessionCursusRepository::class),
  10. ORM\Table(name: 'channel_user_data_cursus_session'),
  11. ]
  12. class SessionCursus extends AbstractCursus
  13. {
  14. #[
  15. ORM\ManyToOne(targetEntity: Session::class),
  16. ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')
  17. ]
  18. #[Assert\NotBlank]
  19. #[IdGroups(['Sync'])]
  20. private ?Session $session = null;
  21. public function getSession(): ?Session
  22. {
  23. return $this->session;
  24. }
  25. public function setSession(?Session $session): static
  26. {
  27. $this->session = $session;
  28. $this->setTraining($session->getTraining());
  29. return $this;
  30. }
  31. public function getLabel(): ?string
  32. {
  33. $label = parent::getLabel();
  34. $sessionLabel = $this->session?->getLabel();
  35. if ($label && $sessionLabel) {
  36. return $label . ' - ' . $sessionLabel;
  37. }
  38. return $sessionLabel;
  39. }
  40. public function getLabelType(): string
  41. {
  42. return $this->session ? $this->session->getLabel() : '';
  43. }
  44. }