src/Entity/Location.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LocationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassLocationRepository::class)]
  8. class Location
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length20)]
  15.     private $type;
  16.     #[ORM\Column(type'string'length255)]
  17.     private $name;
  18.     #[ORM\Column(type'string'length10)]
  19.     private $acronym;
  20.     #[ORM\Embedded(class: Address::class)]
  21.     private $address;
  22.     #[ORM\OneToMany(mappedBy'location'targetEntitySlot::class)]
  23.     private $slots;
  24.     public function __construct()
  25.     {
  26.         $this->slots = new ArrayCollection();
  27.     }
  28.     public function __toString(): string
  29.     {
  30.         return sprintf('%s %s (%s)'$this->getType(), $this->getName(), $this->getAcronym());
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getType(): ?string
  37.     {
  38.         return $this->type;
  39.     }
  40.     public function setType(string $type): self
  41.     {
  42.         $this->type $type;
  43.         return $this;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     public function getAcronym(): ?string
  55.     {
  56.         return $this->acronym;
  57.     }
  58.     public function setAcronym(string $acronym): self
  59.     {
  60.         $this->acronym $acronym;
  61.         return $this;
  62.     }
  63.     public function getAddress(): ?Address
  64.     {
  65.         return $this->address;
  66.     }
  67.     public function setAddress(?Address $address): self
  68.     {
  69.         $this->address $address;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Slot>
  74.      */
  75.     public function getSlots(): Collection
  76.     {
  77.         return $this->slots;
  78.     }
  79.     public function addSlot(Slot $slot): self
  80.     {
  81.         if (!$this->slots->contains($slot)) {
  82.             $this->slots[] = $slot;
  83.             $slot->setLocation($this);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeSlot(Slot $slot): self
  88.     {
  89.         if ($this->slots->removeElement($slot)) {
  90.             // set the owning side to null (unless already changed)
  91.             if ($slot->getLocation() === $this) {
  92.                 $slot->setLocation(null);
  93.             }
  94.         }
  95.         return $this;
  96.     }
  97. }