128 lines
2.8 KiB
PHP
128 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\User\Framework\Entity;
|
|
|
|
use App\User\Framework\Repository\PreferencesRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: PreferencesRepository::class)]
|
|
class Preference
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\Column]
|
|
private ?string $id = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $type = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $name = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $description = null;
|
|
|
|
#[ORM\Column]
|
|
private ?bool $enabled = null;
|
|
|
|
/**
|
|
* @var Collection<int, PreferenceOption>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: PreferenceOption::class, mappedBy: 'preference', fetch: 'EAGER')]
|
|
private Collection $preferenceOptions;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->preferenceOptions = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?string
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setId(string $id): static
|
|
{
|
|
$this->id = $id;
|
|
return $this;
|
|
}
|
|
|
|
public function setName(?string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getType(): ?string
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
public function setType(string $type): static
|
|
{
|
|
$this->type = $type;
|
|
return $this;
|
|
}
|
|
|
|
public function getDescription(): ?string
|
|
{
|
|
return $this->description;
|
|
}
|
|
|
|
public function setDescription(?string $description): static
|
|
{
|
|
$this->description = $description;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isEnabled(): ?bool
|
|
{
|
|
return $this->enabled;
|
|
}
|
|
|
|
public function setEnabled(bool $enabled): static
|
|
{
|
|
$this->enabled = $enabled;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, PreferenceOption>
|
|
*/
|
|
public function getPreferenceOptions(): Collection
|
|
{
|
|
return $this->preferenceOptions;
|
|
}
|
|
|
|
public function addPreferenceOption(PreferenceOption $preferenceOption): static
|
|
{
|
|
if (!$this->preferenceOptions->contains($preferenceOption)) {
|
|
$this->preferenceOptions->add($preferenceOption);
|
|
$preferenceOption->setPreference($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removePreferenceOption(PreferenceOption $preferenceOption): static
|
|
{
|
|
if ($this->preferenceOptions->removeElement($preferenceOption)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($preferenceOption->getPreference() === $this) {
|
|
$preferenceOption->setPreference(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|