<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\MessagePrototypeRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=MessagePrototypeRepository::class)
* @ApiResource(
* denormalizationContext={
* "groups"={"message_prototype:write"}
* },
* normalizationContext={
* "groups"={"message_prototype:read"}
* },
* collectionOperations={
* "post"={"security"="is_granted('ROLE_ADMIN')"},
* "get"={"security"="is_granted('ROLE_USER')"},
* },
* itemOperations={
* "get"={"security"="is_granted('ROLE_USER')"},
* "delete"={"security"="is_granted('ROLE_ADMIN')"},
* "patch"={"security"="is_granted('ROLE_ADMIN')"},
* }
* )
*/
class MessagePrototype extends TvConfiguration
{
/**
* @var string
* @Groups({"message_prototype:write","message_prototype:read"})
* @Assert\Type(type="string")
* @Assert\NotBlank(allowNull=false)
*/
private $subject;
/**
* @var string
* @Groups({"message_prototype:write","message_prototype:read"})
* @Assert\Type(type="string")
* @Assert\NotBlank(allowNull=false)
* @Assert\Email
*/
private $recipients;
/**
* @return string
*/
public function getSubject() : ?string
{
$this->subject = $this->subject??$this->field;
return $this->subject;
}
/**
* @param int|string $subject
* @return MessagePrototype
*/
public function setSubject($subject): MessagePrototype
{
$this->subject = $subject;
$this->field = $subject;
return $this;
}
/**
* @return string
*/
public function getRecipients(): ?string
{
$this->recipients = $this->recipients??$this->value;
return $this->recipients;
}
/**
* @param string $recipients
* @return MessagePrototype
*/
public function setRecipients(string $recipients): MessagePrototype
{
$this->recipients = $recipients;
$this->value = $recipients;
return $this;
}
public function setField(string $field): TvConfiguration
{
$this->field = $field;
$this->subject = $field;
return $this;
}
public function setValue(string $value): TvConfiguration
{
$this->value = $value;
$this->recipients = $value;
return $this;
}
}