src/Entity/Product.php line 44

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  4. use ApiPlatform\Metadata\ApiFilter;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Get;
  7. use ApiPlatform\Metadata\GetCollection;
  8. use ApiPlatform\Metadata\Patch;
  9. use ApiPlatform\Serializer\Filter\PropertyFilter;
  10. use App\Repository\ProductRepository;
  11. use DateTimeImmutable;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use function Symfony\Component\String\u;
  17. #[ORM\Entity(repositoryClassProductRepository::class)]
  18. #[ApiFilter(PropertyFilter::class)]
  19. #[ApiResource(
  20.     shortName'Produkte',
  21.     description'Wordpress Theme / Plugins',
  22.     operations: [
  23.         new Get(uriTemplate'/product/{id}'),
  24.         new GetCollection(uriTemplate'/product'paginationEnabledfalse),
  25.     ],
  26.     formats: [
  27.         'jsonld',
  28.         'json',
  29.         'jsonhal',
  30.         'html',
  31.         'csv' => 'text/csv',
  32.     ],
  33.     normalizationContext: [
  34.         'groups' => ['product:read'],
  35.     ],
  36.     denormalizationContext: [
  37.         'groups' => ['product:write'],
  38.     ],
  39. )]
  40. class Product
  41. {
  42.     #[ORM\Id]
  43.     #[ORM\GeneratedValue]
  44.     #[ORM\Column]
  45.     #[Groups(['product:read''lizenz:read'])]
  46.     private ?int $id null;
  47.     #[ORM\OneToOne(inversedBy"product"targetEntityProductDashboard::class, cascade: ["persist""remove"])]
  48.     #[ORM\JoinColumn(name"productDashboard"nullablefalse)]
  49.     protected ?ProductDashboard $productDashboard;
  50.     #[ORM\OneToOne(inversedBy"product"targetEntityUpdateChecker::class, cascade: ["persist""remove"])]
  51.     #[ORM\JoinColumn(name"updateChecker"nullabletrue)]
  52.     protected ?UpdateChecker $updateChecker;
  53.     #[ORM\Column(length128)]
  54.     #[Groups(['product:read'])]
  55.     #[Assert\NotBlank]
  56.     #[ApiFilter(SearchFilter::class, strategy'partial')]
  57.     private ?string $bezeichnung null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     #[Groups(['product:read'])]
  60.     private ?string $beschreibung null;
  61.     #[ORM\Column(typeTypes::SMALLINT)]
  62.     #[Groups(['product:read'])]
  63.     #[Assert\NotBlank]
  64.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  65.     private ?int $type null;
  66.     #[ORM\Column(length11)]
  67.     #[Groups(['product:read''lizenz:read'])]
  68.     #[Assert\NotBlank]
  69.     private ?string $version null;
  70.     #[ORM\Column]
  71.     #[Groups(['product:read'])]
  72.     #[Assert\NotBlank]
  73.     private ?bool $is_git null;
  74.     #[ORM\Column(length128nullabletrue)]
  75.     #[Groups(['product:read'])]
  76.     private ?string $git_url null;
  77.     #[ORM\Column(length128)]
  78.     #[Groups(['product:read'])]
  79.     #[Assert\NotBlank]
  80.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  81.     private ?string $slug null;
  82.     #[ORM\Column]
  83.     #[Groups(['product:read'])]
  84.     #[Assert\NotBlank]
  85.     private ?bool $is_license null;
  86.     #[ORM\Column]
  87.     #[Groups(['product:read'])]
  88.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  89.     #[Assert\NotBlank]
  90.     private ?bool $is_show_api null;
  91.     #[ORM\Column(length255nullabletrue)]
  92.     //#[Groups(['product:read'])]
  93.     private ?string $aktivierungs_path null;
  94.     #[ORM\Column]
  95.     #[Groups(['product:read'])]
  96.     private ?DateTimeImmutable $created_at null;
  97.     #[ORM\Column(length32nullabletrue)]
  98.     private ?string $gitVersion null;
  99.     #[Groups(['product:read'])]
  100.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  101.     #[ORM\Column(nullabletrueoptions: ['default' => false])]
  102.     private ?bool $is_standalone null;
  103.     public function __construct()
  104.     {
  105.         $this->created_at = new DateTimeImmutable();
  106.     }
  107.     /**
  108.      * @return ProductDashboard|null
  109.      */
  110.     public function getProductDashboard(): ?ProductDashboard
  111.     {
  112.         return $this->productDashboard;
  113.     }
  114.     /**
  115.      * @param ProductDashboard|null $productDashboard
  116.      */
  117.     public function setProductDashboard(?ProductDashboard $productDashboard): void
  118.     {
  119.         $this->productDashboard $productDashboard;
  120.     }
  121.     public function getId(): ?int
  122.     {
  123.         return $this->id;
  124.     }
  125.     public function getBezeichnung(): ?string
  126.     {
  127.         return $this->bezeichnung;
  128.     }
  129.     public function setBezeichnung(string $bezeichnung): self
  130.     {
  131.         $this->bezeichnung $bezeichnung;
  132.         return $this;
  133.     }
  134.     public function getBeschreibung(): ?string
  135.     {
  136.         return $this->beschreibung;
  137.     }
  138.     #[Groups(['product:read'])]
  139.     public function getShortBeschreibung(): ?string
  140.     {
  141.         return u($this->getBeschreibung())->truncate(40'...');
  142.     }
  143.     public function setBeschreibung(?string $beschreibung): self
  144.     {
  145.         $this->beschreibung $beschreibung;
  146.         return $this;
  147.     }
  148.     public function getType(): ?int
  149.     {
  150.         return $this->type;
  151.     }
  152.     public function setType(int $type): self
  153.     {
  154.         $this->type $type;
  155.         return $this;
  156.     }
  157.     public function getVersion(): ?string
  158.     {
  159.         return $this->version;
  160.     }
  161.     public function setVersion(string $version): self
  162.     {
  163.         $this->version $version;
  164.         return $this;
  165.     }
  166.     public function isIsGit(): ?bool
  167.     {
  168.         return $this->is_git;
  169.     }
  170.     public function setIsGit(bool $is_git): self
  171.     {
  172.         $this->is_git $is_git;
  173.         return $this;
  174.     }
  175.     public function getGitUrl(): ?string
  176.     {
  177.         return $this->git_url;
  178.     }
  179.     public function setGitUrl(?string $git_url): self
  180.     {
  181.         $this->git_url $git_url;
  182.         return $this;
  183.     }
  184.     public function getSlug(): ?string
  185.     {
  186.         return $this->slug;
  187.     }
  188.     public function setSlug(string $slug): self
  189.     {
  190.         $this->slug $slug;
  191.         return $this;
  192.     }
  193.     public function isIsLicense(): ?bool
  194.     {
  195.         return $this->is_license;
  196.     }
  197.     public function setIsLicense(bool $is_license): self
  198.     {
  199.         $this->is_license $is_license;
  200.         return $this;
  201.     }
  202.     public function isIsShowApi(): ?bool
  203.     {
  204.         return $this->is_show_api;
  205.     }
  206.     public function setIsShowApi(bool $is_show_api): self
  207.     {
  208.         $this->is_show_api $is_show_api;
  209.         return $this;
  210.     }
  211.     public function getAktivierungsPath(): ?string
  212.     {
  213.         return $this->aktivierungs_path;
  214.     }
  215.     public function setAktivierungsPath(?string $aktivierungs_path): self
  216.     {
  217.         $this->aktivierungs_path $aktivierungs_path;
  218.         return $this;
  219.     }
  220.     public function getCreatedAt(): ?DateTimeImmutable
  221.     {
  222.         return $this->created_at;
  223.     }
  224.     public function setCreatedAt(DateTimeImmutable $created_at): self
  225.     {
  226.         $this->created_at $created_at;
  227.         return $this;
  228.     }
  229.     public function getUpdateChecker(): ?UpdateChecker
  230.     {
  231.         return $this->updateChecker;
  232.     }
  233.     public function setUpdateChecker(?UpdateChecker $updateChecker): self
  234.     {
  235.         $this->updateChecker $updateChecker;
  236.         return $this;
  237.     }
  238.     public function getGitVersion(): ?string
  239.     {
  240.         return $this->gitVersion;
  241.     }
  242.     public function setGitVersion(?string $gitVersion): self
  243.     {
  244.         $this->gitVersion $gitVersion;
  245.         return $this;
  246.     }
  247.     public function isStandalone(): ?bool
  248.     {
  249.         return $this->is_standalone;
  250.     }
  251.     public function setIsStandalone(bool $is_standalone): self
  252.     {
  253.         $this->is_standalone $is_standalone;
  254.         return $this;
  255.     }
  256. }