<?php
namespace App\Entity;
use App\Repository\PackageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass:PackageRepository::class)]
class Package
{
public function __construct()
{
$this->persons = new ArrayCollection();
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type: 'integer', unique: true)]
private $id;
#[ORM\Column(type: 'string', length: 60, unique: true)]
private $type;
#[ORM\ManyToMany(targetEntity: 'App\Entity\Person', mappedBy: 'packages', cascade: ['persist'])]
protected $persons;
/**
* @return mixed
*/
public function getPersons()
{
return $this->persons;
}
public function addPerson(Person $person){
$this->persons->add($person);
}
public function removePerson(Person $person){
$this->persons->removeElement($person);
}
#[ORM\Column(type: 'integer', nullable: true)]
private $unicity;
#[ORM\OneToOne(targetEntity: AdapterContent::class, mappedBy: 'package', cascade: ['persist', 'remove'])]
private $adapterContent;
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, Person>
*/
public function getPerson(): Collection
{
return $this->person;
}
/*public function addPerson(Person $person): self
{
if (!$this->person->contains($person)) {
$this->person[] = $person;
$person->setPackage($this);
}
return $this;
}*/
/* public function removePerson(Person $person): self
{
if ($this->person->removeElement($person)) {
// set the owning side to null (unless already changed)
if ($person->getPackage() === $this) {
$person->setPackage(null);
}
}
return $this;
}*/
public function getUnicity(): ?int
{
return $this->unicity;
}
public function setUnicity(?int $unicity): self
{
$this->unicity = $unicity;
return $this;
}
public function getAdapterContent(): ?AdapterContent
{
return $this->adapterContent;
}
public function setAdapterContent(AdapterContent $adapterContent): self
{
// unset the owning side of the relation if necessary
if ($adapterContent === null && $this->adapterContent !== null) {
$this->adapterContent->setPackage(null);
}
// set the owning side of the relation if necessary
if ($adapterContent !== null && $adapterContent->getPackage() !== $this) {
$adapterContent->setPackage($this);
}
$this->adapterContent = $adapterContent;
return $this;
}
}