src/Entity/MarkupStrategy.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MarkupStrategyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassMarkupStrategyRepository::class)]
  8. class MarkupStrategy
  9. {
  10.     public const PRODUCT_HOTEL 1;
  11.     public const PRODUCT_TRANSFER 2;
  12.     public const PRODUCT_FLIGHT 3;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\OneToMany(mappedBy'markupStrategy'targetEntityMarkupRule::class)]
  20.     private Collection $rules;
  21.     #[ORM\OneToMany(mappedBy'markupStrategy'targetEntityCustomerXmlApi::class)]
  22.     private Collection $customerXmlApis;
  23.     #[ORM\Column(type'integer'nullablefalse)]
  24.     private ?int $product null;
  25.     #[ORM\OneToMany(mappedBy'b2cMarkupStrategy'targetEntityXmlApi::class)]
  26.     private Collection $b2cXmlApis;
  27.     #[ORM\OneToMany(mappedBy'b2bMarkupStrategy'targetEntityXmlApi::class)]
  28.     private Collection $b2bXmlApis;
  29.     public function __construct()
  30.     {
  31.         $this->rules = new ArrayCollection();
  32.         $this->customerXmlApis = new ArrayCollection();
  33.         $this->b2cXmlApis = new ArrayCollection();
  34.         $this->b2bXmlApis = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getProduct(): ?int
  41.     {
  42.         return $this->product;
  43.     }
  44.     public function setProduct(?int $product): static
  45.     {
  46.         $this->product $product;
  47.         return $this;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): static
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return Collection<int, MarkupRule>
  60.      */
  61.     public function getRules(): Collection
  62.     {
  63.         return $this->rules;
  64.     }
  65.     public function addRule(MarkupRule $rule): static
  66.     {
  67.         if (!$this->rules->contains($rule)) {
  68.             $this->rules->add($rule);
  69.             $rule->setMarkupStrategy($this);
  70.         }
  71.         return $this;
  72.     }
  73.     public function removeRule(MarkupRule $rule): static
  74.     {
  75.         if ($this->rules->removeElement($rule)) {
  76.             // set the owning side to null (unless already changed)
  77.             if ($rule->getMarkupStrategy() === $this) {
  78.                 $rule->setMarkupStrategy(null);
  79.             }
  80.         }
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return Collection<int, CustomerXmlApi>
  85.      */
  86.     public function getCustomerXmlApis(): Collection
  87.     {
  88.         return $this->customerXmlApis;
  89.     }
  90.     public function addCustomerXmlApi(CustomerXmlApi $customerXmlApi): static
  91.     {
  92.         if (!$this->customerXmlApis->contains($customerXmlApi)) {
  93.             $this->customerXmlApis->add($customerXmlApi);
  94.             $customerXmlApi->setMarkupStrategy($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeCustomerXmlApi(CustomerXmlApi $customerXmlApi): static
  99.     {
  100.         if ($this->customerXmlApis->removeElement($customerXmlApi)) {
  101.             // set the owning side to null (unless already changed)
  102.             if ($customerXmlApi->getMarkupStrategy() === $this) {
  103.                 $customerXmlApi->setMarkupStrategy(null);
  104.             }
  105.         }
  106.         return $this;
  107.     }
  108.     public function __toString(): string
  109.     {
  110.         return $this->name ?? ' ';
  111.     }
  112.     public static function getProductStrategies(): array
  113.     {
  114.         return [
  115.             'Hotel' => self::PRODUCT_HOTEL,
  116.             'Transfer' => self::PRODUCT_TRANSFER,
  117.             'Flight' => self::PRODUCT_FLIGHT,
  118.         ];
  119.     }
  120.     public function getProductName(): string
  121.     {
  122.         $productNames = [
  123.             self::PRODUCT_HOTEL => 'Hotel',
  124.             self::PRODUCT_TRANSFER => 'Transfer',
  125.             self::PRODUCT_FLIGHT => 'Flight',
  126.         ];
  127.         return $productNames[$this->product] ?? 'Unknown';
  128.     }
  129.     /**
  130.      * @return Collection<int, XmlApi>
  131.      */
  132.     public function getB2cXmlApis(): Collection
  133.     {
  134.         return $this->b2cXmlApis;
  135.     }
  136.     public function addB2cXmlApi(XmlApi $b2cXmlApi): static
  137.     {
  138.         if (!$this->b2cXmlApis->contains($b2cXmlApi)) {
  139.             $this->b2cXmlApis->add($b2cXmlApi);
  140.             $b2cXmlApi->setB2cMarkupStrategy($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeB2cXmlApi(XmlApi $b2cXmlApi): static
  145.     {
  146.         if ($this->b2cXmlApis->removeElement($b2cXmlApi)) {
  147.             // set the owning side to null (unless already changed)
  148.             if ($b2cXmlApi->getB2cMarkupStrategy() === $this) {
  149.                 $b2cXmlApi->setB2cMarkupStrategy(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection<int, XmlApi>
  156.      */
  157.     public function getB2bXmlApis(): Collection
  158.     {
  159.         return $this->b2bXmlApis;
  160.     }
  161.     public function addB2bXmlApi(XmlApi $b2bXmlApi): static
  162.     {
  163.         if (!$this->b2bXmlApis->contains($b2bXmlApi)) {
  164.             $this->b2bXmlApis->add($b2bXmlApi);
  165.             $b2bXmlApi->setB2bMarkupStrategy($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeB2bXmlApi(XmlApi $b2bXmlApi): static
  170.     {
  171.         if ($this->b2bXmlApis->removeElement($b2bXmlApi)) {
  172.             // set the owning side to null (unless already changed)
  173.             if ($b2bXmlApi->getB2bMarkupStrategy() === $this) {
  174.                 $b2bXmlApi->setB2bMarkupStrategy(null);
  175.             }
  176.         }
  177.         return $this;
  178.     }
  179. }