src/Entity/SocialMedia.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\SocialMediaRepository;
  5. use App\Traits\Timestamps;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ORM\Entity(repositoryClassSocialMediaRepository::class)]
  11. #[ApiResource(
  12.     normalizationContext: ['groups' => ['social_media:read']],
  13.     denormalizationContext: ['groups' => ['social_media:write']]
  14. )]
  15. #[ORM\HasLifecycleCallbacks]
  16. class SocialMedia
  17. {
  18.     public CONST NETWORK_INSTAGRAM 'instagram';
  19.     public CONST NETWORK_YOUTUBE 'youtube';
  20.     public CONST NETWORK_TWITTER 'twitter';
  21.     public CONST NETWORK_TIKTOK 'tiktok';
  22.     public CONST NETWORK_FACEBOOK 'facebook';
  23.     use Timestamps;
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     private ?int $id null;
  28.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  29.     private ?string $url null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $network null;
  32.     #[ORM\Column(length255nullabletrue)]
  33.     private ?string $profileId null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $clientExternalId null;
  36.     #[ORM\Column]
  37.     private ?bool $status false;
  38.     #[ORM\OneToMany(mappedBy'socialMedia'targetEntityRecordSocialMedia::class,cascade: ['persist'], orphanRemovaltrue)]
  39.     private Collection $recordSocialMedia;
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $profileName null;
  42.     #[ORM\Column]
  43.     private ?bool $collectData true;
  44.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  45.     private ?string $thumbnail null;
  46.     #[ORM\Column(type'boolean'options: ['default' => false])]
  47.     private ?bool $seen false;
  48.     #[ORM\Column]
  49.     private ?bool $oldDataCollected false;
  50.     public function __construct()
  51.     {
  52.         $this->recordSocialMedia = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getUrl(): ?string
  59.     {
  60.         return $this->url;
  61.     }
  62.     public function setUrl(?string $url): self
  63.     {
  64.         $this->url $url;
  65.         return $this;
  66.     }
  67.     public function getNetwork(): ?string
  68.     {
  69.         return $this->network;
  70.     }
  71.     public function setNetwork(string $network): self
  72.     {
  73.         $this->network $network;
  74.         return $this;
  75.     }
  76.     public function getProfileId(): ?string
  77.     {
  78.         return $this->profileId;
  79.     }
  80.     public function setProfileId(?string $profileId): self
  81.     {
  82.         $this->profileId $profileId;
  83.         return $this;
  84.     }
  85.     public function getClientExternalId(): ?string
  86.     {
  87.         return $this->clientExternalId;
  88.     }
  89.     public function setClientExternalId(?string $clientExternalId): self
  90.     {
  91.         $this->clientExternalId $clientExternalId;
  92.         return $this;
  93.     }
  94.     public function isStatus(): ?bool
  95.     {
  96.         return $this->status;
  97.     }
  98.     public function setStatus(bool $status): static
  99.     {
  100.         $this->status $status;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, RecordSocialMedia>
  105.      */
  106.     public function getRecordSocialMedia(): Collection
  107.     {
  108.         return $this->recordSocialMedia;
  109.     }
  110.     public function addRecordSocialMedium(RecordSocialMedia $recordSocialMedium): static
  111.     {
  112.         if (!$this->recordSocialMedia->contains($recordSocialMedium)) {
  113.             $this->recordSocialMedia->add($recordSocialMedium);
  114.             $recordSocialMedium->setSocialMedia($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeRecordSocialMedium(RecordSocialMedia $recordSocialMedium): static
  119.     {
  120.         if ($this->recordSocialMedia->removeElement($recordSocialMedium)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($recordSocialMedium->getSocialMedia() === $this) {
  123.                 $recordSocialMedium->setSocialMedia(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     public function getProfileName(): ?string
  129.     {
  130.         return $this->profileName;
  131.     }
  132.     public function __toString(): string
  133.     {
  134.         return $this->profileName ?? '';
  135.     }
  136.     public function setProfileName(?string $profileName): static
  137.     {
  138.         $this->profileName $profileName;
  139.         return $this;
  140.     }
  141.     public function isCollectData(): ?bool
  142.     {
  143.         return $this->collectData;
  144.     }
  145.     public function setCollectData(bool $collectData): static
  146.     {
  147.         $this->collectData $collectData;
  148.         return $this;
  149.     }
  150.     public function getThumbnail(): ?string
  151.     {
  152.         return $this->thumbnail;
  153.     }
  154.     public function setThumbnail(?string $thumbnail): static
  155.     {
  156.         $this->thumbnail $thumbnail;
  157.         return $this;
  158.     }
  159.     public function isSeen(): ?bool
  160.     {
  161.         return $this->seen;
  162.     }
  163.     public function setSeen(bool $seen): static
  164.     {
  165.         $this->seen $seen;
  166.         return $this;
  167.     }
  168.     public function isOldDataCollected(): ?bool
  169.     {
  170.         return $this->oldDataCollected;
  171.     }
  172.     public function setOldDataCollected(bool $oldDataCollected): static
  173.     {
  174.         $this->oldDataCollected $oldDataCollected;
  175.         return $this;
  176.     }
  177.     public function isInstagram(): bool
  178.     {
  179.         return $this->network === self::NETWORK_INSTAGRAM;
  180.     }
  181. }