src/Entity/Messaging/Subject.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Messaging;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\App\Messaging\SubjectRepository")
  9.  */
  10. class Subject
  11. {
  12.     public const TEAM_TYPE_DEFAULT 'TEAM_TYPE_DEFAULT';
  13.     public const TEAM_TYPE_CONTRACT 'TEAM_TYPE_CONTRACT';
  14.     public const TEAM_TYPE_EXPLOITATION_CENTER 'TEAM_TYPE_EXPLOITATION_CENTER';
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     protected $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      * @Assert\NotBlank
  24.      */
  25.     protected $label;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\Messaging\Theme", inversedBy="subjects")
  28.      * @ORM\JoinColumn(nullable=false)
  29.      * @Assert\NotBlank
  30.      */
  31.     protected $theme;
  32.     /**
  33.      * @ORM\Column(type="boolean")
  34.      * @Assert\Type(type="boolean")
  35.      */
  36.     protected $requiredContract false;
  37.     /**
  38.      * @ORM\Column(type="boolean", nullable=true)
  39.      * @Assert\Type(type="boolean")
  40.      */
  41.     protected $information false;
  42.     /**
  43.      * @ORM\Column(type="string", length=255)
  44.      * @Assert\NotBlank
  45.      */
  46.     protected $contactFormType;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity="App\Entity\Messaging\RedirectLink", mappedBy="subject", cascade={"persist"}, orphanRemoval=true)
  49.      */
  50.     protected $redirectLinks;
  51.     /**
  52.      * @ORM\Column(type="string", length=255)
  53.      * @Assert\Choice(choices={
  54.      *     Subject::TEAM_TYPE_DEFAULT,
  55.      *     Subject::TEAM_TYPE_CONTRACT,
  56.      *     Subject::TEAM_TYPE_EXPLOITATION_CENTER,
  57.      * })
  58.      */
  59.     protected $teamType Subject::TEAM_TYPE_DEFAULT;
  60.     /**
  61.      * @ORM\ManyToOne(targetEntity="App\Entity\Messaging\Team")
  62.      * @Assert\Expression(
  63.      *     "value !== null or (this.getRequiredContract() and this.getTeamType() !== constant('App\\Entity\\Messaging\\Subject::TEAM_TYPE_DEFAULT'))",
  64.      *     message="This value should not be blank."
  65.      * )
  66.      */
  67.     protected $team;
  68.     /**
  69.      * @ORM\OneToMany(targetEntity="App\Entity\Messaging\Conversation", mappedBy="subject", orphanRemoval=true)
  70.      */
  71.     protected $conversations;
  72.     /**
  73.      * @ORM\Column(type="boolean")
  74.      */
  75.     protected $archived false;
  76.     public function __construct()
  77.     {
  78.         $this->redirectLinks = new ArrayCollection();
  79.         $this->conversations = new ArrayCollection();
  80.     }
  81.     public function getId(): ?int
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function getLabel(): ?string
  86.     {
  87.         return $this->label;
  88.     }
  89.     public function setLabel(string $label): self
  90.     {
  91.         $this->label $label;
  92.         return $this;
  93.     }
  94.     public function getTheme(): ?Theme
  95.     {
  96.         return $this->theme;
  97.     }
  98.     public function setTheme(?Theme $theme): self
  99.     {
  100.         $this->theme $theme;
  101.         return $this;
  102.     }
  103.     public function getRequiredContract(): bool
  104.     {
  105.         return $this->requiredContract;
  106.     }
  107.     public function setRequiredContract(bool $requiredContract): self
  108.     {
  109.         $this->requiredContract $requiredContract;
  110.         return $this;
  111.     }
  112.     public function getInformation(): ?bool
  113.     {
  114.         return $this->information;
  115.     }
  116.     public function setInformation(bool $information): self
  117.     {
  118.         $this->information $information;
  119.         return $this;
  120.     }
  121.     public function getContactFormType(): ?string
  122.     {
  123.         return $this->contactFormType;
  124.     }
  125.     public function setContactFormType(string $contactFormType): self
  126.     {
  127.         $this->contactFormType $contactFormType;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection|RedirectLink[]
  132.      */
  133.     public function getRedirectLinks(): Collection
  134.     {
  135.         return $this->redirectLinks;
  136.     }
  137.     public function addRedirectLink(RedirectLink $redirectLink): self
  138.     {
  139.         if (!$this->redirectLinks->contains($redirectLink)) {
  140.             $this->redirectLinks[] = $redirectLink;
  141.             $redirectLink->setSubject($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeRedirectLink(RedirectLink $redirectLink): self
  146.     {
  147.         if ($this->redirectLinks->contains($redirectLink)) {
  148.             $this->redirectLinks->removeElement($redirectLink);
  149.             if ($redirectLink->getSubject() === $this) {
  150.                 $redirectLink->setSubject(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155.     public function getTeamType(): ?string
  156.     {
  157.         return $this->teamType;
  158.     }
  159.     public function setTeamType(string $teamType): self
  160.     {
  161.         $this->teamType $teamType;
  162.         return $this;
  163.     }
  164.     public function getTeam(): ?Team
  165.     {
  166.         return $this->team;
  167.     }
  168.     public function setTeam(?Team $team): self
  169.     {
  170.         $this->team $team;
  171.         return $this;
  172.     }
  173.     public function getConversations(): Collection
  174.     {
  175.         return $this->conversations;
  176.     }
  177.     public function isArchived(): bool
  178.     {
  179.         return $this->archived;
  180.     }
  181.     public function setArchived(bool $archived): void
  182.     {
  183.         $this->archived $archived;
  184.     }
  185.     public function __toString()
  186.     {
  187.         return $this->label;
  188.     }
  189. }