AccessIntangible.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use App\Repository\Billing\AccessIntangibleRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12. * Enregistrement d'un produit à facturer par un Access.
  13. */
  14. #[ApiResource(operations: [])]
  15. // #[Auditable]
  16. #[ORM\Entity(repositoryClass: AccessIntangibleRepository::class)]
  17. class AccessIntangible extends AbstractBillingIntangible
  18. {
  19. #[ORM\ManyToOne(inversedBy: 'accessIntangibles')]
  20. private ?Access $access = null;
  21. #[ORM\OneToMany(mappedBy: 'accessIntangible', targetEntity: BillingIntangibleExcludeDate::class, cascade: ['persist'], orphanRemoval: true)]
  22. private Collection $billingIntangibleExcludeDates;
  23. public function __construct()
  24. {
  25. $this->billingIntangibleExcludeDates = new ArrayCollection();
  26. }
  27. public function setAccess(?Access $access): self
  28. {
  29. $this->access = $access;
  30. return $this;
  31. }
  32. public function getAccess(): ?Access
  33. {
  34. return $this->access;
  35. }
  36. /**
  37. * @return Collection<int, BillingIntangibleExcludeDate>
  38. */
  39. public function getBillingIntangibleExcludeDates(): Collection
  40. {
  41. return $this->billingIntangibleExcludeDates;
  42. }
  43. public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  44. {
  45. if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
  46. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  47. $billingIntangibleExcludeDate->setAccessIntangible($this);
  48. }
  49. return $this;
  50. }
  51. public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  52. {
  53. if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
  54. // set the owning side to null (unless already changed)
  55. if ($billingIntangibleExcludeDate->getAccessIntangible() === $this) {
  56. $billingIntangibleExcludeDate->setAccessIntangible(null);
  57. }
  58. }
  59. return $this;
  60. }
  61. }