<?php
namespace App\Entity;
use App\Repository\TenantRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TenantRepository::class)
*
* @ORM\HasLifecycleCallbacks()
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class Tenant {
use MetaTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $hostname;
/**
* @ORM\Column(type="string", length=255)
*/
private $uploadDirectory;
/**
* @ORM\OneToOne(targetEntity=TenantConfig::class, mappedBy="tenant", cascade={"persist", "remove"})
*/
private $tenantConfig;
/**
* @ORM\OneToMany(targetEntity=Faq::class, mappedBy="tenant")
*/
private $faqs;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="tenant")
*/
private $products;
/**
* @ORM\OneToMany(targetEntity=TextTemplate::class, mappedBy="tenant", orphanRemoval=true, fetch="EXTRA_LAZY")
*/
private $textTemplates;
/**
* @ORM\OneToMany(targetEntity=Category::class, mappedBy="tenant", orphanRemoval=true)
*/
private $categories;
/**
* @ORM\OneToMany(targetEntity=Order::class, mappedBy="tenant", orphanRemoval=true)
*/
private $orders;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $dvoEmail;
private $initialUser;
public function __construct() {
$this->faqs = new ArrayCollection();
$this->products = new ArrayCollection();
$this->textTemplates = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->orders = new ArrayCollection();
}
/**
* @return string
*/
public function __toString(): string {
return $this->getName();
}
/**
* @return int|null
*/
public function getId(): ?int {
return $this->id;
}
/**
* @return string
*/
public function getName(): string {
return $this->name;
}
/**
* @param string $name
*
* @return self
*/
public function setName(string $name): self {
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getHostname(): string {
return $this->hostname;
}
/**
* @param string $hostname
*
* @return self
*/
public function setHostname(string $hostname): self {
$this->hostname = $hostname;
return $this;
}
/**
* @return string
*/
public function getUploadDirectory(): string {
return $this->uploadDirectory;
}
/**
* @param string $uploadDirectory
*
* @return self
*/
public function setUploadDirectory(string $uploadDirectory): self {
$this->uploadDirectory = $uploadDirectory;
return $this;
}
/**
* @return TenantConfig|null
*/
public function getTenantConfig(): ?TenantConfig {
return $this->tenantConfig;
}
/**
* @return bool
*/
public function hasTenangConfig(): bool {
return $this->tenantConfig !== null;
}
/**
* @param TenantConfig $tenantConfig
*
* @return self
*/
public function setTenantConfig(TenantConfig $tenantConfig): self {
// set the owning side of the relation if necessary
if ($tenantConfig->getTenant() !== $this) {
$tenantConfig->setTenant($this);
}
$this->tenantConfig = $tenantConfig;
return $this;
}
/**
* @return Collection|Faq[]
*/
public function getFaqs(): Collection {
return $this->faqs;
}
/**
* @param Faq $faq
*
* @return self
*/
public function addFaq(Faq $faq): self {
if (!$this->faqs->contains($faq)) {
$this->faqs[] = $faq;
$faq->setTenant($this);
}
return $this;
}
/**
* @param Faq $faq
*
* @return self
*/
public function removeFaq(Faq $faq): self {
if ($this->faqs->removeElement($faq)) {
// set the owning side to null (unless already changed)
if ($faq->getTenant() === $this) {
$faq->setTenant(null);
}
}
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProducts(): Collection {
return $this->products;
}
/**
* @param Product $product
*
* @return self
*/
public function addProduct(Product $product): self {
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setTenant($this);
}
return $this;
}
/**
* @param Product $product
*
* @return self
*/
public function removeProduct(Product $product): self {
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getTenant() === $this) {
$product->setTenant(null);
}
}
return $this;
}
/**
* @return Collection|TextTemplate[]
*/
public function getTextTemplates(): Collection {
return $this->textTemplates;
}
/**
* @param TextTemplate $textTemplate
*
* @return self
*/
public function addTextTemplate(TextTemplate $textTemplate): self {
if (!$this->textTemplates->contains($textTemplate)) {
$this->textTemplates[] = $textTemplate;
$textTemplate->setTenant($this);
}
return $this;
}
/**
* @param TextTemplate $textTemplate
*
* @return self
*/
public function removeTextTemplate(TextTemplate $textTemplate): self {
if ($this->textTemplates->removeElement($textTemplate)) {
// set the owning side to null (unless already changed)
if ($textTemplate->getTenant() === $this) {
$textTemplate->setTenant(null);
}
}
return $this;
}
/**
* @ORM\PrePersist
*/
public function setDefaults(): self {
return $this
->setCreatedAt(new \DateTime());
}
/**
* @ORM\PreUpdate
*/
public function setModified(): self {
return $this
->setModifiedAt(new \DateTime());
}
/**
* @return Collection<int, Category>
*/
public function getCategories(): Collection {
return $this->categories;
}
/**
* @param Category $category
*
* @return self
*/
public function addCategory(Category $category): self {
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
$category->setTenant($this);
}
return $this;
}
/**
* @param Category $category
*
* @return self
*/
public function removeCategory(Category $category): self {
if ($this->categories->removeElement($category)) {
// set the owning side to null (unless already changed)
if ($category->getTenant() === $this) {
$category->setTenant(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection {
return $this->orders;
}
/**
* @param Order $order
*
* @return self
*/
public function addOrder(Order $order): self {
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setTenant($this);
}
return $this;
}
/**
* @param Order $order
*
* @return self
*/
public function removeOrder(Order $order): self {
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getTenant() === $this) {
$order->setTenant(null);
}
}
return $this;
}
/**
* @return string|null
*/
public function getEmail(): ?string {
return $this->email;
}
/**
* @param string $email
*
* @return self
*/
public function setEmail(string $email): self {
$this->email = $email;
return $this;
}
/**
* @return string|null
*/
public function getDvoEmail(): ?string {
return $this->dvoEmail;
}
/**
* @param string $dvoEmail
*
* @return self
*/
public function setDvoEmail(string $dvoEmail): self {
$this->dvoEmail = $dvoEmail;
return $this;
}
/**
* @return User|null
*/
public function getInitialUser(): ?User {
return $this->initialUser;
}
/**
* @param User|null $initialUser
*
* @return self
*/
public function setInitialUser(?User $initialUser): self {
$this->initialUser = $initialUser;
return $this;
}
}