<?php
namespace App\Entity\Channel;
use App\Entity\Sync\SyncableInterface;
use App\Repository\Channel\TrainingRepository;
use Doctrine\ORM\Mapping as ORM;
use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
use Nellapp\Bundle\SDKBundle\Channel\Entity\Training\TrainingInterface;
use Nellapp\Bundle\SDKBundle\Channel\Entity\Training\TrainingMethodTrait;
use Nellapp\Bundle\SDKBundle\Permission\Entity\ChannelResourceInterface;
use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
use Symfony\Component\Serializer\Annotation as Serial;
use Symfony\Component\Validator\Constraints as Assert;
#[
ORM\Entity(repositoryClass: TrainingRepository::class),
ORM\Table(name: 'channel_trainings'),
ORM\Index(columns: ['name'], flags: ['fulltext']),
ORM\Index(columns: ['description'], flags: ['fulltext']),
]
class Training implements TrainingInterface, SyncableInterface, ChannelResourceInterface
{
use TrainingMethodTrait;
#[ORM\Id, ORM\GeneratedValue(strategy: "NONE"), ORM\Column(type: 'string', length: 36)]
#[Serial\Groups(['Manager', 'Sync'])]
private ?string $id = null;
#[ORM\Column(type: 'string', length: 255)]
#[Serial\Groups(['Manager', 'Sync'])]
#[
Assert\NotBlank(message: 'scholar.training.name.NotBlank'),
Assert\Length(
min: 2,
max: 255,
minMessage: 'scholar.training.name.Length.min',
maxMessage: 'scholar.training.name.Length.max',
)
]
private ?string $name = null;
#[ORM\Column(type: 'text', nullable: true)]
#[Assert\Length(
min: 20,
max: 2000,
minMessage: 'scholar.training.description.Length.min',
maxMessage: 'scholar.training.description.Length.max',
)]
#[Serial\Groups(['Manager', 'Sync'])]
private ?string $description = null;
#[ORM\ManyToOne(targetEntity: Channel::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[IdGroups(['Sync'])]
private Channel $ownerChannel;
#[ORM\Column(type: 'datetime', nullable: true)]
#[Serial\Groups(['Manager'])]
private ?\DateTimeInterface $createdAt = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[Serial\Groups(['Manager'])]
private ?\DateTimeInterface $updatedAt = null;
#[ORM\Column(type: 'boolean', nullable: false)]
private ?bool $isActive = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $diplomaDescription = null;
public static function getSyncKey(): string
{
return EntityKeys::CHANNEL_TRAINING;
}
public function getSyncDisplayLabel(): string
{
return (string) $this->getName();
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): static
{
$this->isActive = $isActive;
return $this;
}
public function getDiplomaDescription(): ?string
{
return $this->diplomaDescription;
}
public function setDiplomaDescription(?string $diplomaDescription): Training
{
$this->diplomaDescription = $diplomaDescription;
return $this;
}
public static function getPermissionResourceClass(): ?string
{
return ChannelUserTrainingPermission::class;
}
}