<?php
namespace App\Entity\Messaging;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\App\Messaging\SubjectRepository")
*/
class Subject
{
public const TEAM_TYPE_DEFAULT = 'TEAM_TYPE_DEFAULT';
public const TEAM_TYPE_CONTRACT = 'TEAM_TYPE_CONTRACT';
public const TEAM_TYPE_EXPLOITATION_CENTER = 'TEAM_TYPE_EXPLOITATION_CENTER';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank
*/
protected $label;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Messaging\Theme", inversedBy="subjects")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank
*/
protected $theme;
/**
* @ORM\Column(type="boolean")
* @Assert\Type(type="boolean")
*/
protected $requiredContract = false;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Assert\Type(type="boolean")
*/
protected $information = false;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank
*/
protected $contactFormType;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Messaging\RedirectLink", mappedBy="subject", cascade={"persist"}, orphanRemoval=true)
*/
protected $redirectLinks;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Choice(choices={
* Subject::TEAM_TYPE_DEFAULT,
* Subject::TEAM_TYPE_CONTRACT,
* Subject::TEAM_TYPE_EXPLOITATION_CENTER,
* })
*/
protected $teamType = Subject::TEAM_TYPE_DEFAULT;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Messaging\Team")
* @Assert\Expression(
* "value !== null or (this.getRequiredContract() and this.getTeamType() !== constant('App\\Entity\\Messaging\\Subject::TEAM_TYPE_DEFAULT'))",
* message="This value should not be blank."
* )
*/
protected $team;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Messaging\Conversation", mappedBy="subject", orphanRemoval=true)
*/
protected $conversations;
/**
* @ORM\Column(type="boolean")
*/
protected $archived = false;
public function __construct()
{
$this->redirectLinks = new ArrayCollection();
$this->conversations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getTheme(): ?Theme
{
return $this->theme;
}
public function setTheme(?Theme $theme): self
{
$this->theme = $theme;
return $this;
}
public function getRequiredContract(): bool
{
return $this->requiredContract;
}
public function setRequiredContract(bool $requiredContract): self
{
$this->requiredContract = $requiredContract;
return $this;
}
public function getInformation(): ?bool
{
return $this->information;
}
public function setInformation(bool $information): self
{
$this->information = $information;
return $this;
}
public function getContactFormType(): ?string
{
return $this->contactFormType;
}
public function setContactFormType(string $contactFormType): self
{
$this->contactFormType = $contactFormType;
return $this;
}
/**
* @return Collection|RedirectLink[]
*/
public function getRedirectLinks(): Collection
{
return $this->redirectLinks;
}
public function addRedirectLink(RedirectLink $redirectLink): self
{
if (!$this->redirectLinks->contains($redirectLink)) {
$this->redirectLinks[] = $redirectLink;
$redirectLink->setSubject($this);
}
return $this;
}
public function removeRedirectLink(RedirectLink $redirectLink): self
{
if ($this->redirectLinks->contains($redirectLink)) {
$this->redirectLinks->removeElement($redirectLink);
if ($redirectLink->getSubject() === $this) {
$redirectLink->setSubject(null);
}
}
return $this;
}
public function getTeamType(): ?string
{
return $this->teamType;
}
public function setTeamType(string $teamType): self
{
$this->teamType = $teamType;
return $this;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): self
{
$this->team = $team;
return $this;
}
public function getConversations(): Collection
{
return $this->conversations;
}
public function isArchived(): bool
{
return $this->archived;
}
public function setArchived(bool $archived): void
{
$this->archived = $archived;
}
public function __toString()
{
return $this->label;
}
}