src/Entity/Channel/Training.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Sync\SyncableInterface;
  4. use App\Repository\Channel\TrainingRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  7. use Nellapp\Bundle\SDKBundle\Channel\Entity\Training\TrainingInterface;
  8. use Nellapp\Bundle\SDKBundle\Channel\Entity\Training\TrainingMethodTrait;
  9. use Nellapp\Bundle\SDKBundle\Permission\Entity\ChannelResourceInterface;
  10. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  11. use Symfony\Component\Serializer\Annotation as Serial;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[
  14. ORM\Entity(repositoryClass: TrainingRepository::class),
  15. ORM\Table(name: 'channel_trainings'),
  16. ORM\Index(columns: ['name'], flags: ['fulltext']),
  17. ORM\Index(columns: ['description'], flags: ['fulltext']),
  18. ]
  19. class Training implements TrainingInterface, SyncableInterface, ChannelResourceInterface
  20. {
  21. use TrainingMethodTrait;
  22. #[ORM\Id, ORM\GeneratedValue(strategy: "NONE"), ORM\Column(type: 'string', length: 36)]
  23. #[Serial\Groups(['Manager', 'Sync'])]
  24. private ?string $id = null;
  25. #[ORM\Column(type: 'string', length: 255)]
  26. #[Serial\Groups(['Manager', 'Sync'])]
  27. #[
  28. Assert\NotBlank(message: 'scholar.training.name.NotBlank'),
  29. Assert\Length(
  30. min: 2,
  31. max: 255,
  32. minMessage: 'scholar.training.name.Length.min',
  33. maxMessage: 'scholar.training.name.Length.max',
  34. )
  35. ]
  36. private ?string $name = null;
  37. #[ORM\Column(type: 'text', nullable: true)]
  38. #[Assert\Length(
  39. min: 20,
  40. max: 2000,
  41. minMessage: 'scholar.training.description.Length.min',
  42. maxMessage: 'scholar.training.description.Length.max',
  43. )]
  44. #[Serial\Groups(['Manager', 'Sync'])]
  45. private ?string $description = null;
  46. #[ORM\ManyToOne(targetEntity: Channel::class)]
  47. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  48. #[IdGroups(['Sync'])]
  49. private Channel $ownerChannel;
  50. #[ORM\Column(type: 'datetime', nullable: true)]
  51. #[Serial\Groups(['Manager'])]
  52. private ?\DateTimeInterface $createdAt = null;
  53. #[ORM\Column(type: 'datetime', nullable: true)]
  54. #[Serial\Groups(['Manager'])]
  55. private ?\DateTimeInterface $updatedAt = null;
  56. #[ORM\Column(type: 'boolean', nullable: false)]
  57. #[Serial\Groups(['Sync'])]
  58. private ?bool $isActive = null;
  59. #[ORM\Column(type: 'text', nullable: true)]
  60. private ?string $diplomaDescription = null;
  61. public static function getSyncKey(): string
  62. {
  63. return EntityKeys::CHANNEL_TRAINING;
  64. }
  65. public function getSyncDisplayLabel(): string
  66. {
  67. return (string) $this->getName();
  68. }
  69. public function setIsActive(?bool $isActive): static
  70. {
  71. $this->isActive = $isActive;
  72. return $this;
  73. }
  74. public function getDiplomaDescription(): ?string
  75. {
  76. return $this->diplomaDescription;
  77. }
  78. public function setDiplomaDescription(?string $diplomaDescription): Training
  79. {
  80. $this->diplomaDescription = $diplomaDescription;
  81. return $this;
  82. }
  83. public static function getPermissionResourceClass(): ?string
  84. {
  85. return ChannelUserTrainingPermission::class;
  86. }
  87. }