src/Entity/SiteSeo.php line 81

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  4. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\Delete;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\Patch;
  11. use ApiPlatform\Metadata\Post;
  12. use ApiPlatform\Metadata\Put;
  13. use ApiPlatform\Serializer\Filter\PropertyFilter;
  14. use App\Repository\SiteSeoRepository;
  15. use DateTimeImmutable;
  16. use Doctrine\DBAL\Types\Types;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. use App\Filter\SearchAnnotation as Searchable;
  21. #[ORM\Entity(repositoryClassSiteSeoRepository::class)]
  22. #[ApiFilter(PropertyFilter::class)]
  23. #[ApiResource(
  24.     shortName'Site Seo',
  25.     description'Studio API',
  26.     operations: [
  27.         new Get(uriTemplate'/seo/{id}'),
  28.         new Patch(uriTemplate'/seo/{id}',security"is_granted('ROLE_OAUTH2_BASIC')"),
  29.         new Put(uriTemplate'/seo/{id}',security"is_granted('ROLE_OAUTH2_BASIC')"),
  30.         new Post(uriTemplate'/seo',security"is_granted('ROLE_OAUTH2_BASIC')"),
  31.         new Delete(uriTemplate'/seo/{id}',security"is_granted('ROLE_OAUTH2_BASIC')"),
  32.         new GetCollection(uriTemplate'/seo'paginationEnabledfalse),
  33.     ],
  34.     formats: [
  35.         'jsonld',
  36.         'json',
  37.         'jsonhal',
  38.         'csv' => 'text/csv',
  39.     ],
  40.     normalizationContext: [
  41.         'groups' => ['seo:read'],
  42.     ],
  43.     denormalizationContext: [
  44.         'groups' => ['seo:write'],
  45.     ],
  46.     filters:['search'],
  47.     // paginationItemsPerPage: 10,
  48. ),
  49.     ApiFilter(
  50.         OrderFilter::class,
  51.         properties: [
  52.             'type',
  53.             'slug',
  54.             'seoTitle',
  55.             'noIndex',
  56.             'noFollow',
  57.             'fbAktiv',
  58.             'xAktiv',
  59.             'createdAt',
  60.         ],
  61.     ),
  62.     ApiFilter(
  63.         SearchFilter::class,
  64.         properties: [
  65.             //'seoContent',
  66.             // 'seoTitle',
  67.         ],
  68.     ),
  69. ]
  70. /**
  71.  * @Searchable({"seoContent", "seoTitle", "ogType", "ogTitle", "ogContent", "xType", "xSite", "xCreator"})
  72.  */
  73. class SiteSeo
  74. {
  75.     #[ORM\Id]
  76.     #[ORM\GeneratedValue]
  77.     #[ORM\Column]
  78.     #[Groups(['seo:read''studio:read'])]
  79.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  80.     private ?int $id null;
  81.     #[ORM\Column(length28)]
  82.     #[Groups(['seo:read''seo:write''studio:read'])]
  83.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  84.     #[Assert\NotBlank]
  85.     #[Assert\Length(min1max28maxMessage'Describe your loot in 1-28 chars or less')]
  86.     // #[ApiFilter(RegexpFilter::class)]
  87.         //http://example.com/offers?regexp_type=^[FOO]
  88.     private ?string $type null;
  89.     #[ORM\Column(length64nullabletrue)]
  90.     #[Groups(['seo:read''seo:write''studio:read'])]
  91.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  92.     private ?string $slug null;
  93.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  94.     #[Groups(['seo:read''seo:write''studio:read'])]
  95.     #[ApiFilter(SearchFilter::class, strategy'search')]
  96.     private ?string $seoContent null;
  97.     #[ORM\Column(length255nullabletrue)]
  98.     #[Groups(['seo:read''seo:write''studio:read'])]
  99.     #[ApiFilter(SearchFilter::class, strategy'search')]
  100.     private ?string $seoTitle null;
  101.     #[ORM\OneToOne(mappedBy'siteSeo'targetEntityStudio::class)]
  102.     #[Groups(['seo:read','seo:write'])]
  103.     protected ?Studio $studio;
  104.     #[ORM\Column]
  105.     private ?DateTimeImmutable $createdAt null;
  106.     #[Groups(['seo:read''seo:write''studio:read'])]
  107.     #[ORM\Column]
  108.     private ?bool $noIndex null;
  109.     #[ORM\Column]
  110.     #[Groups(['seo:read''seo:write''studio:read'])]
  111.     private ?bool $noFollow null;
  112.     #[ORM\Column]
  113.     #[Groups(['seo:read''seo:write''studio:read'])]
  114.     private ?bool $fbAktiv null;
  115.     #[ORM\Column]
  116.     #[Groups(['seo:read''seo:write''studio:read'])]
  117.     private ?bool $xAktiv null;
  118.     #[ORM\Column(length64nullabletrue)]
  119.     #[Groups(['seo:read''seo:write''studio:read'])]
  120.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  121.     private ?string $ogType null;
  122.     #[Groups(['seo:read''seo:write''studio:read'])]
  123.     #[ORM\Column(length255nullabletrue)]
  124.     #[ApiFilter(SearchFilter::class, strategy'partial')]
  125.     private ?string $ogTitle null;
  126.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  127.     #[Groups(['seo:read''seo:write''studio:read'])]
  128.     #[ApiFilter(SearchFilter::class, strategy'partial')]
  129.     private ?string $ogContent null;
  130.     #[ORM\Column(nullabletrue)]
  131.     #[Groups(['seo:read''seo:write''studio:read'])]
  132.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  133.     private ?int $ogImage null;
  134.     #[ORM\Column(length64nullabletrue)]
  135.     #[Groups(['seo:read''seo:write''studio:read'])]
  136.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  137.     private ?string $xType null;
  138.     #[ORM\Column(length64nullabletrue)]
  139.     #[Groups(['seo:read''seo:write''studio:read'])]
  140.     #[ApiFilter(SearchFilter::class, strategy'partial')]
  141.     private ?string $xSite null;
  142.     #[ORM\Column(length64nullabletrue)]
  143.     #[Groups(['seo:read''seo:write''studio:read'])]
  144.     #[ApiFilter(SearchFilter::class, strategy'partial')]
  145.     private ?string $xCreator null;
  146.     #[ORM\Column(length255nullabletrue)]
  147.     #[Groups(['seo:read''seo:write''studio:read'])]
  148.     private ?string $fbAppId null;
  149.     #[ORM\Column(length255nullabletrue)]
  150.     #[Groups(['seo:read''seo:write''studio:read'])]
  151.     private ?string $fbAdmins null;
  152.     #[ORM\Column(length6nullabletrueoptions: ['default' => ' â€“ '])]
  153.     #[Groups(['seo:read''seo:write''studio:read'])]
  154.     private ?string $seoSeparator null;
  155.     #[ORM\Column(length64nullabletrue)]
  156.     #[Groups(['seo:read''seo:write''studio:read'])]
  157.     private ?string $titlePrefix null;
  158.     #[ORM\Column(length64nullabletrue)]
  159.     #[Groups(['seo:read''seo:write''studio:read'])]
  160.     private ?string $titleSuffix null;
  161.     public function __construct()
  162.     {
  163.         $this->createdAt = new DateTimeImmutable();
  164.         $this->noIndex false;
  165.         $this->noFollow false;
  166.         $this->fbAktiv false;
  167.         $this->xAktiv false;
  168.         $this->ogType 'website';
  169.         $this->xType 'summary';
  170.     }
  171.     public function getId(): ?int
  172.     {
  173.         return $this->id;
  174.     }
  175.     public function getType(): ?string
  176.     {
  177.         return $this->type;
  178.     }
  179.     public function setType(string $type): self
  180.     {
  181.         $this->type $type;
  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 getStudio(): ?Studio
  194.     {
  195.         return $this->studio;
  196.     }
  197.     public function setStudio(?Studio $studio): self
  198.     {
  199.         // unset the owning side of the relation if necessary
  200.         if ($studio === null && $this->studio !== null) {
  201.             $this->studio->setSiteSeo(null);
  202.         }
  203.         // set the owning side of the relation if necessary
  204.         if ($studio !== null && $studio->getSiteSeo() !== $this) {
  205.             $studio->setSiteSeo($this);
  206.         }
  207.         $this->studio $studio;
  208.         return $this;
  209.     }
  210.     public function getCreatedAt(): ?DateTimeImmutable
  211.     {
  212.         return $this->createdAt;
  213.     }
  214.     public function setCreatedAt(DateTimeImmutable $createdAt): self
  215.     {
  216.         $this->createdAt $createdAt;
  217.         return $this;
  218.     }
  219.     #[Groups(['seo:read'])]
  220.     public function getSeoOrderCreatedAt(): ?DateTimeImmutable
  221.     {
  222.         return $this->createdAt;
  223.     }
  224.     public function getSeoTitle(): ?string
  225.     {
  226.         return $this->seoTitle;
  227.     }
  228.     public function setSeoTitle(string $seoTitle): self
  229.     {
  230.         $this->seoTitle $seoTitle;
  231.         return $this;
  232.     }
  233.     public function getSeoContent(): ?string
  234.     {
  235.         return $this->seoContent;
  236.     }
  237.     public function setSeoContent(?string $seoContent): self
  238.     {
  239.         $this->seoContent $seoContent;
  240.         return $this;
  241.     }
  242.     public function isNoIndex(): ?bool
  243.     {
  244.         return $this->noIndex;
  245.     }
  246.     public function setNoIndex(bool $noIndex): self
  247.     {
  248.         $this->noIndex $noIndex;
  249.         return $this;
  250.     }
  251.     public function isNoFollow(): ?bool
  252.     {
  253.         return $this->noFollow;
  254.     }
  255.     public function setNoFollow(bool $noFollow): self
  256.     {
  257.         $this->noFollow $noFollow;
  258.         return $this;
  259.     }
  260.     public function isFbAktiv(): ?bool
  261.     {
  262.         return $this->fbAktiv;
  263.     }
  264.     public function setFbAktiv(bool $fbAktiv): self
  265.     {
  266.         $this->fbAktiv $fbAktiv;
  267.         return $this;
  268.     }
  269.     public function isXAktiv(): ?bool
  270.     {
  271.         return $this->xAktiv;
  272.     }
  273.     public function setXAktiv(bool $xAktiv): self
  274.     {
  275.         $this->xAktiv $xAktiv;
  276.         return $this;
  277.     }
  278.     public function getOgType(): ?string
  279.     {
  280.         return $this->ogType;
  281.     }
  282.     public function setOgType(?string $ogType): self
  283.     {
  284.         $this->ogType $ogType;
  285.         return $this;
  286.     }
  287.     public function getXType(): ?string
  288.     {
  289.         return $this->xType;
  290.     }
  291.     public function setXType(?string $xType): self
  292.     {
  293.         $this->xType $xType;
  294.         return $this;
  295.     }
  296.     public function getXSite(): ?string
  297.     {
  298.         return $this->xSite;
  299.     }
  300.     public function setXSite(?string $xSite): self
  301.     {
  302.         $this->xSite $xSite;
  303.         return $this;
  304.     }
  305.     public function getXCreator(): ?string
  306.     {
  307.         return $this->xCreator;
  308.     }
  309.     public function setXCreator(?string $xCreator): self
  310.     {
  311.         $this->xCreator $xCreator;
  312.         return $this;
  313.     }
  314.     public function getOgTitle(): ?string
  315.     {
  316.         return $this->ogTitle;
  317.     }
  318.     public function setOgTitle(?string $ogTitle): self
  319.     {
  320.         $this->ogTitle $ogTitle;
  321.         return $this;
  322.     }
  323.     public function getOgContent(): ?string
  324.     {
  325.         return $this->ogContent;
  326.     }
  327.     public function setOgContent(?string $ogContent): self
  328.     {
  329.         $this->ogContent $ogContent;
  330.         return $this;
  331.     }
  332.     public function getOgImage(): ?int
  333.     {
  334.         return $this->ogImage;
  335.     }
  336.     public function setOgImage(?int $ogImage): self
  337.     {
  338.         $this->ogImage $ogImage;
  339.         return $this;
  340.     }
  341.     public function getFbAppId(): ?string
  342.     {
  343.         return $this->fbAppId;
  344.     }
  345.     public function setFbAppId(?string $fbAppId): self
  346.     {
  347.         $this->fbAppId $fbAppId;
  348.         return $this;
  349.     }
  350.     public function getFbAdmins(): ?string
  351.     {
  352.         return $this->fbAdmins;
  353.     }
  354.     public function setFbAdmins(?string $fbAdmins): self
  355.     {
  356.         $this->fbAdmins $fbAdmins;
  357.         return $this;
  358.     }
  359.     public function getSeoSeparator(): ?string
  360.     {
  361.         return $this->seoSeparator;
  362.     }
  363.     public function setSeoSeparator(?string $seoSeparator): self
  364.     {
  365.         $this->seoSeparator $seoSeparator;
  366.         return $this;
  367.     }
  368.     public function getTitlePrefix(): ?string
  369.     {
  370.         return $this->titlePrefix;
  371.     }
  372.     public function setTitlePrefix(?string $titlePrefix): self
  373.     {
  374.         $this->titlePrefix $titlePrefix;
  375.         return $this;
  376.     }
  377.     public function getTitleSuffix(): ?string
  378.     {
  379.         return $this->titleSuffix;
  380.     }
  381.     public function setTitleSuffix(?string $titleSuffix): self
  382.     {
  383.         $this->titleSuffix $titleSuffix;
  384.         return $this;
  385.     }
  386. }