218 lines
5.2 KiB
PHP
218 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\WorldmarkRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|
|
|
#[ORM\Entity(repositoryClass: WorldmarkRepository::class)]
|
|
#[ORM\Index(columns: ['slug'])]
|
|
#[UniqueEntity(fields: ['slug'], message: 'There is already a worldmark with this slug')]
|
|
class Worldmark {
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column(type: 'integer', options: ['unsigned' => true])]
|
|
private $id;
|
|
|
|
#[ORM\ManyToOne(targetEntity: WorldmarkCategory::class)]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private $category;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Item::class)]
|
|
private $item;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Monster::class)]
|
|
private $monster;
|
|
|
|
#[ORM\Column(type: 'string', length: 60)]
|
|
private $name;
|
|
|
|
#[ORM\Column(type: 'string', length: 60, unique: true)]
|
|
private $slug;
|
|
|
|
#[ORM\Column(type: 'text', nullable: true)]
|
|
private $description;
|
|
|
|
#[ORM\Column(type: 'tinyint', options: ['default' => 1, 'unsigned' => true])]
|
|
private $defaultQuantityValue;
|
|
|
|
#[ORM\Column(type: 'tinyint', options: ['default' => 0, 'unsigned' => true])]
|
|
private $defaultPrimogemValue;
|
|
|
|
#[ORM\Column(type: 'string', length: 50, nullable: true)]
|
|
private $icon;
|
|
|
|
#[ORM\Column(type: 'boolean', options: ['default' => 1])]
|
|
private $canBeHidden;
|
|
|
|
#[ORM\Column(type: 'float')]
|
|
private $version;
|
|
|
|
#[ORM\Column(type: 'smallint', options: ['default' => 65535, 'unsigned' => true])]
|
|
private $sortOrder;
|
|
|
|
#[ORM\ManyToMany(targetEntity: Region::class, inversedBy: 'worldmarks')]
|
|
#[ORM\JoinTable(name: 'region_worldmark')]
|
|
private $regions;
|
|
|
|
public function __construct() {
|
|
$this->defaultQuantityValue = 1;
|
|
$this->defaultPrimogemValue = 0;
|
|
$this->canBeHidden = 1;
|
|
$this->regions=new ArrayCollection();
|
|
}
|
|
|
|
public function __toString(): string {
|
|
return $this->getName();
|
|
}
|
|
|
|
public function getId(): ?int {
|
|
return $this->id;
|
|
}
|
|
|
|
public function getCategory(): WorldmarkCategory {
|
|
return $this->category;
|
|
}
|
|
|
|
public function setCategory(WorldmarkCategory $category): self {
|
|
$this->category=$category;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getItem(): ?Item {
|
|
return $this->item;
|
|
}
|
|
|
|
public function setItem(?Item $item): self {
|
|
$this->item=$item;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getMonster(): ?Monster {
|
|
return $this->monster;
|
|
}
|
|
|
|
public function setMonster(?Monster $monster): self {
|
|
$this->monster=$monster;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getName(): ?string {
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): self {
|
|
$this->name=$name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSlug(): ?string {
|
|
return $this->slug;
|
|
}
|
|
|
|
public function setSlug(string $slug): self {
|
|
$this->slug=$slug;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDescription(): ?string {
|
|
return $this->description;
|
|
}
|
|
|
|
public function setDescription(?string $description): self {
|
|
$this->description=$description;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDefaultQuantityValue() {
|
|
return $this->defaultQuantityValue;
|
|
}
|
|
|
|
public function setDefaultQuantityValue($defaultQuantityValue): self {
|
|
$this->defaultQuantityValue = $defaultQuantityValue;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDefaultPrimogemValue() {
|
|
return $this->defaultPrimogemValue;
|
|
}
|
|
|
|
public function setDefaultPrimogemValue($defaultPrimogemValue): self {
|
|
$this->defaultPrimogemValue = $defaultPrimogemValue;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIcon(): string|UploadedFile|null {
|
|
return $this->icon;
|
|
}
|
|
|
|
public function setIcon(string|UploadedFile|null $icon): self {
|
|
$this->icon=$icon;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCanBeHidden(): ?bool {
|
|
return $this->canBeHidden;
|
|
}
|
|
|
|
public function setCanBeHidden(bool $canBeHidden): self {
|
|
$this->canBeHidden=$canBeHidden;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getVersion(): ?float {
|
|
return $this->version;
|
|
}
|
|
|
|
public function setVersion(float $version): self {
|
|
$this->version=$version;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSortOrder(): ?int {
|
|
return $this->sortOrder;
|
|
}
|
|
|
|
public function setSortOrder(int $sortOrder): self {
|
|
$this->sortOrder=$sortOrder;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRegions(): Collection {
|
|
return $this->regions;
|
|
}
|
|
|
|
public function addRegion(Region $region): self {
|
|
if(!$this->regions->contains($region)) {
|
|
$this->regions[]=$region;
|
|
$region->addWorldmark($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeRegion(Region $region): self {
|
|
if($this->regions->removeElement($region)) {
|
|
$region->removeWorldmark($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|