| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <?php
- namespace AppBundle\Entity\Message;
- use AppBundle\Annotation\DefaultField;
- use AppBundle\Entity\Core\File;
- use AppBundle\Entity\Organization\Organization;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Template system
- */
- #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Message\Repository\TemplateSystemRepository')]
- #[ORM\Table(name: 'TemplateSystem')]
- #[ORM\UniqueConstraint(name: 'template_organization_idx', columns: ['template', 'organization_id'])]
- class TemplateSystem
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['templatesystem'])]
- private $id;
- /**
- * @var Organization
- *
- * @DefaultField
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization')]
- #[Groups(['templatesystem'])]
- private $organization;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['templatesystem'])]
- private $subject;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string')]
- #[Assert\Type(type: 'string')]
- #[Assert\Choice(callback: ['AppBundle\Enum\Message\TemplateSystemEnum', 'toArray'])]
- #[Groups(['templatesystem'])]
- private $template;
- /**
- * @var string
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['templatesystem'])]
- private $text;
- /**
- * @var ArrayCollection<File>
- */
- #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Core\File', mappedBy: 'templateSystem', orphanRemoval: true)]
- #[Groups(['templatesystem'])]
- private $files;
- public function __construct()
- {
- $this->files = new ArrayCollection();
- }
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set organization
- *
- * @param Organization $organization
- *
- * @return TemplateSystem
- */
- public function setOrganization(Organization $organization = null)
- {
- $this->organization = $organization;
- return $this;
- }
- /**
- * Get organization
- *
- * @return Organization
- */
- public function getOrganization()
- {
- return $this->organization;
- }
- /**
- * Sets subject.
- *
- * @param string $subject
- *
- * @return $this
- */
- public function setSubject($subject)
- {
- $this->subject = $subject;
- return $this;
- }
- /**
- * Gets subject.
- *
- * @return string
- */
- public function getSubject()
- {
- return $this->subject;
- }
- /**
- * Sets template.
- *
- * @param string $template
- *
- * @return $this
- */
- public function setTemplate($template)
- {
- $this->template = $template;
- return $this;
- }
- /**
- * Gets template.
- *
- * @return string
- */
- public function getTemplate()
- {
- return $this->template;
- }
- /**
- * Set text
- *
- * @param string $text
- *
- * @return Message
- */
- public function setText($text)
- {
- $this->text = $text;
- return $this;
- }
- /**
- * Get text
- *
- * @return string
- */
- public function getText()
- {
- return html_entity_decode($this->text);
- }
- /**
- * Adds file.
- *
- * @param File $file
- *
- * @return $this
- */
- public function addFile(File $file)
- {
- $file->setTemplateSystem($this);
- $this->files->add($file);
- return $this;
- }
- /**
- * Removes file.
- *
- * @param File $file
- *
- * @return $this
- */
- public function removeFile(File $file)
- {
- $this->files->removeElement($file);
- return $this;
- }
- /**
- * Gets files.
- *
- * @return ArrayCollection<File>
- */
- public function getFiles()
- {
- return $this->files;
- }
- }
|