src/Entity/User/ShopUser.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\User;
  4. use App\Entity\LicenceFile;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping\MappedSuperclass;
  8. use Doctrine\ORM\Mapping\Table;
  9. use Sylius\Component\Core\Model\ShopUser as BaseShopUser;
  10. use Sylius\Component\Core\Model\ShopUserInterface;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13. * @ORM\Entity()
  14. * @Table(name="sylius_shop_user")
  15. */
  16. class ShopUser extends BaseShopUser implements ShopUserInterface
  17. {
  18. /**
  19. * @ORM\OneToMany(targetEntity="App\Entity\LicenceFile", mappedBy="user", orphanRemoval=true)
  20. */
  21. private $licenceFiles;
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. $this->licenceFiles = new ArrayCollection();
  26. }
  27. /**
  28. * @return Collection|LicenceFile[]
  29. */
  30. public function getLicenceFiles(): Collection
  31. {
  32. return $this->licenceFiles;
  33. }
  34. public function addLicenceFile(LicenceFile $licenceFile): self
  35. {
  36. if (!$this->licenceFiles->contains($licenceFile)) {
  37. $this->licenceFiles[] = $licenceFile;
  38. $licenceFile->setUser($this);
  39. }
  40. return $this;
  41. }
  42. public function removeLicenceFile(LicenceFile $licenceFile): self
  43. {
  44. if ($this->licenceFiles->contains($licenceFile)) {
  45. $this->licenceFiles->removeElement($licenceFile);
  46. // set the owning side to null (unless already changed)
  47. if ($licenceFile->getUser() === $this) {
  48. $licenceFile->setUser(null);
  49. }
  50. }
  51. return $this;
  52. }
  53. }