src/Entity/CustomerXmlApi.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CustomerXmlApiRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Timestampable\Traits\TimestampableEntity;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. #[ORM\Entity(repositoryClassCustomerXmlApiRepository::class)]
  8. #[UniqueEntity(fields:['xmlApi''customer'])]
  9. class CustomerXmlApi
  10. {
  11.     use TimestampableEntity;
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\ManyToOne]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private ?Customer $customer null;
  19.     #[ORM\ManyToOne(targetEntityXmlApi::class, inversedBy"customerXmlApis")]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private ?XmlApi $xmlApi null;
  22.     //#[ORM\Column]
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?float $margin null;
  25.     //#[ORM\Column]
  26.     #[ORM\Column(nullabletrue)]
  27.     private ?bool $xmlOut null;
  28.     #[ORM\ManyToOne(inversedBy'customerXmlApis')]
  29.     private ?MarkupStrategy $markupStrategy null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?float $commission null;
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getCustomer(): ?Customer
  37.     {
  38.         return $this->customer;
  39.     }
  40.     public function setCustomer(?Customer $customer): static
  41.     {
  42.         $this->customer $customer;
  43.         return $this;
  44.     }
  45.     public function getXmlApi(): ?XmlApi
  46.     {
  47.         return $this->xmlApi;
  48.     }
  49.     public function setXmlApi(?XmlApi $xmlApi): static
  50.     {
  51.         $this->xmlApi $xmlApi;
  52.         return $this;
  53.     }
  54.     public function getMargin(): ?float
  55.     {
  56.         return $this->margin;
  57.     }
  58.     /*
  59.     public function setMargin(float $margin): static
  60.     {
  61.         $this->margin = $margin;
  62.         return $this;
  63.     }
  64.     */
  65.     public function setMargin(?float $margin): static
  66.     {
  67.         $this->margin $margin;
  68.         return $this;
  69.     }
  70.     public function isXmlOut(): ?bool
  71.     {
  72.         return $this->xmlOut;
  73.     }
  74.     /*
  75.     public function setXmlOut(bool $xmlOut): static
  76.     {
  77.         $this->xmlOut = $xmlOut;
  78.         return $this;
  79.     }
  80.     */
  81.     public function setXmlOut(?bool $xmlOut): static
  82.     {
  83.         $this->xmlOut $xmlOut;
  84.         return $this;
  85.     }
  86.     public function __toString(): string
  87.     {
  88.         return $this->xmlApi->getName();
  89.     }
  90.     public function getMarkupStrategy(): ?MarkupStrategy
  91.     {
  92.         return $this->markupStrategy;
  93.     }
  94.     public function setMarkupStrategy(?MarkupStrategy $markupStrategy): static
  95.     {
  96.         $this->markupStrategy $markupStrategy;
  97.         return $this;
  98.     }
  99.     private function getCustomerName(): string
  100.     {
  101.         if ($this->getCustomer()) {
  102.             $customer $this->getCustomer();
  103.             $name $customer->getName();
  104.             $type $customer instanceof CustomerMoral 'BTOB' 'BTOC';
  105.             return $name ' - ' $type;
  106.         }
  107.         return ' ';
  108.     }
  109.        public function getNameCustomer(): object
  110.        {
  111.            return new class($this->getCustomerName(), $this->getId()) {
  112.              public function __construct(public string $name, public int $id) {}
  113.                public function __toString() {
  114.                    return $this->name;
  115.                }
  116.            };
  117.        }
  118.        public function getCommission(): ?float
  119.        {
  120.            return $this->commission;
  121.        }
  122.        public function setCommission(?float $commission): static
  123.        {
  124.            $this->commission $commission;
  125.            return $this;
  126.        }
  127. }