src/Entity/MarketApp.php line 34

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use App\Entity\Traits\CreatedAtTrait;
  7. use App\Entity\Traits\UpdatedAtTrait;
  8. use App\Repository\MarketAppRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Bridge\Doctrine\Types\UlidType;
  14. use Symfony\Component\HttpFoundation\File\File;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Uid\Ulid;
  17. use Symfony\Component\Uid\Uuid;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  20. #[ORM\HasLifecycleCallbacks]
  21. #[Vich\Uploadable]
  22. #[ORM\Entity(repositoryClassMarketAppRepository::class)]
  23. #[ApiResource(
  24.     operations: [
  25.         new Get(),
  26.         new GetCollection(),
  27.     ],
  28.     normalizationContext: ['groups' => 'read'],
  29.     paginationEnabledfalse
  30. )]
  31. class MarketApp
  32. {
  33.     use CreatedAtTrait;
  34.     use UpdatedAtTrait;
  35.     #[ORM\Id]
  36.     #[ORM\GeneratedValue]
  37.     #[ORM\Column]
  38.     #[Groups(['read''MarketCategory:read'])]
  39.     private ?int $id null;
  40.     #[Vich\UploadableField(mapping'icon_file'fileNameProperty'icon')]
  41.     #[Assert\Image(mimeTypes: ['image/png''image/jpeg''image/jpg'])]
  42.     private ?File $iconFile null;
  43.     #[ORM\Column(length255nullabletrue)]
  44.     #[Groups(['read''MarketCategory:read'])]
  45.     private ?string $icon null;
  46.     #[ORM\Column(length255)]
  47.     #[Groups(['read''MarketCategory:read'])]
  48.     private ?string $name null;
  49.     #[ORM\Column(length255)]
  50.     #[Groups(['read''MarketCategory:read'])]
  51.     private ?string $developer null;
  52.     #[ORM\Column(length2000)]
  53.     #[Groups(['read''MarketCategory:read'])]
  54.     private ?string $description null;
  55.     #[ORM\Column(length500)]
  56.     #[Groups(['read''MarketCategory:read'])]
  57.     private ?string $shortDescription null;
  58.     #[ORM\Column(length500)]
  59.     #[Groups(['read''MarketCategory:read'])]
  60.     private ?string $downloads null;
  61.     #[ORM\Column(length500)]
  62.     #[Groups(['read''MarketCategory:read'])]
  63.     private ?string $url null;
  64.     #[ORM\OneToMany(mappedBy'marketApp'targetEntityMarketAppImage::class, cascade: ['persist''remove'])]
  65.     #[Groups(['read''MarketCategory:read'])]
  66.     private Collection $images;
  67.     #[ORM\Column(typeTypes::DECIMALprecision10scale'0')]
  68.     #[Groups(['read''MarketCategory:read'])]
  69.     private ?string $price null;
  70.     #[ORM\ManyToMany(targetEntityMarketCategory::class, mappedBy'apps')]
  71.     #[Groups(['read'])]
  72.     private Collection $marketCategories;
  73.     public function __construct()
  74.     {
  75.         $this->images = new ArrayCollection();
  76.         $this->marketCategories = new ArrayCollection();
  77.     }
  78.     public function __toString(): string
  79.     {
  80.         return $this->getName();
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getIconFile(): ?File
  87.     {
  88.         return $this->iconFile;
  89.     }
  90.     public function setIconFile(?File $iconFile): void
  91.     {
  92.         $this->iconFile $iconFile;
  93.         if (null !== $iconFile) {
  94.             $this->updatedAt = new \DateTime();
  95.         }
  96.     }
  97.     public function getIcon(): ?string
  98.     {
  99.         return $this->icon;
  100.     }
  101.     public function setIcon(?string $icon): self
  102.     {
  103.         $this->icon $icon;
  104.         return $this;
  105.     }
  106.     public function getName(): ?string
  107.     {
  108.         return $this->name;
  109.     }
  110.     public function setName(string $name): self
  111.     {
  112.         $this->name $name;
  113.         return $this;
  114.     }
  115.     public function getImages(): Collection
  116.     {
  117.         return $this->images;
  118.     }
  119.     public function addImage(MarketAppImage $image): self
  120.     {
  121.         if (!$this->images->contains($image)) {
  122.             $this->images->add($image);
  123.             $image->setMarketApp($this);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removeImage(MarketAppImage $image): self
  128.     {
  129.         if ($this->images->removeElement($image)) {
  130.             // set the owning side to null (unless already changed)
  131.             if ($image->getMarketApp() === $this) {
  132.                 $image->setMarketApp(null);
  133.             }
  134.         }
  135.         return $this;
  136.     }
  137.     public function getDeveloper(): ?string
  138.     {
  139.         return $this->developer;
  140.     }
  141.     public function setDeveloper(string $developer): self
  142.     {
  143.         $this->developer $developer;
  144.         return $this;
  145.     }
  146.     public function getDescription(): ?string
  147.     {
  148.         return $this->description;
  149.     }
  150.     public function setDescription(string $description): self
  151.     {
  152.         $this->description $description;
  153.         return $this;
  154.     }
  155.     public function getShortDescription(): ?string
  156.     {
  157.         return $this->shortDescription;
  158.     }
  159.     public function setShortDescription(string $shortDescription): self
  160.     {
  161.         $this->shortDescription $shortDescription;
  162.         return $this;
  163.     }
  164.     public function getDownloads(): ?string
  165.     {
  166.         return $this->downloads;
  167.     }
  168.     public function setDownloads(string $downloads): self
  169.     {
  170.         $this->downloads $downloads;
  171.         return $this;
  172.     }
  173.     public function getUrl(): ?string
  174.     {
  175.         return $this->url;
  176.     }
  177.     public function setUrl(string $url): self
  178.     {
  179.         $this->url $url;
  180.         return $this;
  181.     }
  182.     public function getPrice(): ?string
  183.     {
  184.         return $this->price;
  185.     }
  186.     public function setPrice(string $price): self
  187.     {
  188.         $this->price $price;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection<int, MarketCategory>
  193.      */
  194.     public function getMarketCategories(): Collection
  195.     {
  196.         return $this->marketCategories;
  197.     }
  198.     public function addMarketCategory(MarketCategory $marketCategory): self
  199.     {
  200.         if (!$this->marketCategories->contains($marketCategory)) {
  201.             $this->marketCategories->add($marketCategory);
  202.             $marketCategory->addApp($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeMarketCategory(MarketCategory $marketCategory): self
  207.     {
  208.         if ($this->marketCategories->removeElement($marketCategory)) {
  209.             $marketCategory->removeApp($this);
  210.         }
  211.         return $this;
  212.     }
  213. }