<?phpnamespace App\Entity;use App\Repository\CustomerXmlApiRepository;use Doctrine\ORM\Mapping as ORM;use Gedmo\Timestampable\Traits\TimestampableEntity;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;#[ORM\Entity(repositoryClass: CustomerXmlApiRepository::class)]#[UniqueEntity(fields:['xmlApi', 'customer'])]class CustomerXmlApi{ use TimestampableEntity; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?Customer $customer = null; #[ORM\ManyToOne(targetEntity: XmlApi::class, inversedBy: "customerXmlApis")] #[ORM\JoinColumn(nullable: false)] private ?XmlApi $xmlApi = null; //#[ORM\Column] #[ORM\Column(nullable: true)] private ?float $margin = null; //#[ORM\Column] #[ORM\Column(nullable: true)] private ?bool $xmlOut = null; #[ORM\ManyToOne(inversedBy: 'customerXmlApis')] private ?MarkupStrategy $markupStrategy = null; #[ORM\Column(nullable: true)] private ?float $commission = null; public function getId(): ?int { return $this->id; } public function getCustomer(): ?Customer { return $this->customer; } public function setCustomer(?Customer $customer): static { $this->customer = $customer; return $this; } public function getXmlApi(): ?XmlApi { return $this->xmlApi; } public function setXmlApi(?XmlApi $xmlApi): static { $this->xmlApi = $xmlApi; return $this; } public function getMargin(): ?float { return $this->margin; } /* public function setMargin(float $margin): static { $this->margin = $margin; return $this; } */ public function setMargin(?float $margin): static { $this->margin = $margin; return $this; } public function isXmlOut(): ?bool { return $this->xmlOut; } /* public function setXmlOut(bool $xmlOut): static { $this->xmlOut = $xmlOut; return $this; } */ public function setXmlOut(?bool $xmlOut): static { $this->xmlOut = $xmlOut; return $this; } public function __toString(): string { return $this->xmlApi->getName(); } public function getMarkupStrategy(): ?MarkupStrategy { return $this->markupStrategy; } public function setMarkupStrategy(?MarkupStrategy $markupStrategy): static { $this->markupStrategy = $markupStrategy; return $this; } private function getCustomerName(): string { if ($this->getCustomer()) { $customer = $this->getCustomer(); $name = $customer->getName(); $type = $customer instanceof CustomerMoral ? 'BTOB' : 'BTOC'; return $name . ' - ' . $type; } return ' '; } public function getNameCustomer(): object { return new class($this->getCustomerName(), $this->getId()) { public function __construct(public string $name, public int $id) {} public function __toString() { return $this->name; } }; } public function getCommission(): ?float { return $this->commission; } public function setCommission(?float $commission): static { $this->commission = $commission; return $this; }}