AccessIntangible.php 2.2 KB

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