src/Entity/CurrencyChange.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CurrencyChangeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CurrencyChangeRepository::class)
  9.  */
  10. class CurrencyChange
  11. {
  12.     const SESSION_KEY 'currency_session';
  13.     const SESSION_VALUE 'currency_value';
  14.     const SESSION_EXCHANGE 'currency_exchange';
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $currency;
  25.     /**
  26.      * @ORM\Column(type="float")
  27.      */
  28.     private $exchangeRate;
  29.     /**
  30.      * @ORM\Column(type="boolean")
  31.      */
  32.     private $enabled;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity=ShippingCurrency::class, mappedBy="exchangRate")
  35.      */
  36.     private $shippings;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=AppUser::class, mappedBy="currency")
  39.      */
  40.     private $users;
  41.     public function __construct()
  42.     {
  43.         $this->shippings = new ArrayCollection();
  44.         $this->users = new ArrayCollection();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getCurrency(): ?string
  51.     {
  52.         return $this->currency;
  53.     }
  54.     public function setCurrency(string $currency): self
  55.     {
  56.         $this->currency $currency;
  57.         return $this;
  58.     }
  59.     public function getExchangeRate(): ?float
  60.     {
  61.         return $this->exchangeRate;
  62.     }
  63.     public function setExchangeRate(float $exchangeRate): self
  64.     {
  65.         $this->exchangeRate $exchangeRate;
  66.         return $this;
  67.     }
  68.     public function isEnabled(): ?bool
  69.     {
  70.         return $this->enabled;
  71.     }
  72.     public function setEnabled(bool $enabled): self
  73.     {
  74.         $this->enabled $enabled;
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, ShippingCurrency>
  79.      */
  80.     public function getShippings(): Collection
  81.     {
  82.         return $this->shippings;
  83.     }
  84.     public function addShipping(ShippingCurrency $shipping): self
  85.     {
  86.         if (!$this->shippings->contains($shipping)) {
  87.             $this->shippings[] = $shipping;
  88.             $shipping->setCurrency($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeShipping(ShippingCurrency $shipping): self
  93.     {
  94.         if ($this->shippings->removeElement($shipping)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($shipping->getCurrency() === $this) {
  97.                 $shipping->setCurrency(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return Collection<int, AppUser>
  104.      */
  105.     public function getUsers(): Collection
  106.     {
  107.         return $this->users;
  108.     }
  109.     public function addUser(AppUser $user): self
  110.     {
  111.         if (!$this->users->contains($user)) {
  112.             $this->users[] = $user;
  113.             $user->setCurrency($this);
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeUser(AppUser $user): self
  118.     {
  119.         if ($this->users->removeElement($user)) {
  120.             // set the owning side to null (unless already changed)
  121.             if ($user->getCurrency() === $this) {
  122.                 $user->setCurrency(null);
  123.             }
  124.         }
  125.         return $this;
  126.     }
  127.     public function __toString()
  128.     {
  129.         return $this->currency;
  130.     }
  131. }